免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1469 | 回复: 0
打印 上一主题 下一主题

JDBC Driver 连接数据库方法列举 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-29 12:46 |只看该作者 |倒序浏览

JDBC Driver连接方法列表
有鑒於許多版友對於尋找JDBC driver或者如何使用driver常常發問,
在這邊我簡單整理一下比較代表性的driver跟使用方式.
Microsoft SQL Server series (6.5, 7.x and 2000) and Sybase 10
JDBC Name: jTDS
URL:
http://jtds.sourceforge.net/
Version: 0.5.1
Download URL:
http://sourceforge.net/project/showfiles.php?group_id=33291
語法:
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://host:port/database","user","password");
or
Connection con = DriverManager.getConnection("jdbc:jtds:sybase://host:port/database","user","password");
MySQL
JDBC Name: Connector/J 3.0
URL:
http://www.mysql.com/
Version: 3.0.8-stable
Download URL:
http://www.mysql.com/downloads/api-jdbc-stable.html
語法:
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://host:port/database","user","password");
Oracle
JDBC Name: Connector/J 3.0
URL:
http://otn.oracle.com/
Version: 3.0.8-stable
Download URL:
http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html
語法:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@host:port:databse","user","password");
Sybase
Driver: jConnect 4.5/5.5 (JDBC 2.0 請使用5.5)
語法:
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:sybase:Tds:[IP位址或機器名稱]:2638?ServiceName=資料庫名稱","帳號","密碼");
Postgresql
JDBC Name: PostgreSQL JDBC
URL:
http://jdbc.postgresql.org/
Version: 7.3.3 build 110
Download URL:
http://jdbc.postgresql.org/download.html
語法:
Class.forName("org.postgresql.Driver");
Connection con=DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");
Informix
Driver:com.informix.jdbc.IfxDriver
語法:
Class.forName("com.informix.jdbc.IfxDriver");
String full_db="jdbc:informix-sqli://10.14.86.11:300/authority: INFORMIXSERVER=ifx9;user=informix;password=informix;NEWLOCALE=en_us,zh_tw;NEWCODESET=Big5,8859-1,819;";
con =DriverManager.getConnection(full_db);
IBM AS400主機在用的JDBC語法
有裝V4R4以上版本的Client Access Express
可以在C:Program FilesIBMClient Accessjt400lib
找到 driver 檔案 jt400.zip,並更改副檔名成為 jt400.jar
語法
java.sql.DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());
Class.forName("com.ibm.as400.access.AS400JDBCConnection");
con = DriverManager.getConnection("jdbc:as400://IP","user","password");

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/28585/showart_409861.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP