Chinaunix首页 | 论坛 | 博客
  • 博客访问: 53351
  • 博文数量: 43
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 460
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-23 02:07
文章分类

全部博文(43)

文章存档

2010年(43)

我的朋友
最近访客

分类: 数据库开发技术

2010-09-24 14:16:22

1、Oracle8/8i/9i数据库(thin模式) 
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); 
String url="jdbc:oracle:thin:@localhost:1521:orcl"; 
//orcl为数据库的SID 
String user="test"; 
String password="test"; 
Connection conn= DriverManager.getConnection(url,user,password); 

2、DB2数据库 
Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance(); 
String url="jdbc:db2://localhost:5000/sample"; 
//sample为你的数据库名 
String user="admin"; 
String password=""; 
Connection conn= DriverManager.getConnection(url,user,password); 

3、Sql Server7.0/2000数据库 
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb"; 
//mydb为数据库 
String user="sa"; 
String password=""; 
Connection conn= DriverManager.getConnection(url,user,password); 

4、Sybase数据库 
Class.forName("com.sybase.jdbc.SybDriver").newInstance(); 
String url =" jdbc:sybase:Tds:localhost:5007/myDB"; 
//myDB为你的数据库名 
Properties sysProps = System.getProperties(); 
SysProps.put("user","userid"); 
SysProps.put("password","user_password"); 
Connection conn= DriverManager.getConnection(url, SysProps); 

5、Informix数据库 
Class.forName("com.informix.jdbc.IfxDriver").newInstance(); 
String url = 
"jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver; 
user=testuser;password=testpassword"; 
//myDB为数据库名 
Connection conn= DriverManager.getConnection(url); 

6、MySQL数据库 
Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 
String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1" 
//myDB为数据库名 
Connection conn= DriverManager.getConnection(url); 

7、PostgreSQL数据库 
Class.forName("org.postgresql.Driver").newInstance(); 
String url ="jdbc:postgresql://localhost/myDB" 
//myDB为数据库名 
String user="myuser"; 
String password="mypassword"; 
Connection conn= DriverManager.getConnection(url,user,password);
阅读(1461) | 评论(2) | 转发(0) |
0

上一篇:数据库连接缓冲池

下一篇:没有了

给主人留下些什么吧!~~

chinaunix网友2010-09-27 07:54:14

很高兴认识你,看看我的博客中的文章吧,对生活很有好处,下面是一些推荐的链接。 电脑一族必看的科学饮食 http://blog.chinaunix.net/u3/119126/showart_2337806.html 抵御电脑辐射从吃开始 http://blog.chinaunix.net/u3/119126/showart_2337785.html 上班族的五种防病食物 http://blog.chinaunix.net/u3/119126/showart_2337764.html 哪些人群最应该喝酸奶 http://blog.chinaunix.net/u3/119126/showart_2337734.html 计算机族必喝的健康饮料 http://blog.chinaunix.net/u3/119126/showart_2337676.html

chinaunix网友2010-09-26 15:19:47

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com