`

各家JDBC driver的現行版本及使用語法 ver.20080708

    博客分类:
  • Java
阅读更多
有鑒於許多版友對於尋找JDBC driver或者如何使用driver常常發問,
在這邊我簡單整理一下比較代表性的driver跟使用方式.

Microsoft SQL Server series (6.5, 7.x, 2000, 2005) 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

語法:

1234
 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");





JDBC Name: MS官方
Download URL:
Microsoft SQL Server 2005 JDBC Driver 1.2
SQL Server 2000 Driver for JDBC Service Pack 3

MS SQL 2000 的JDBC語法:
123
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
 
Connection conn=DriverManager.getConnection("jdbc:sqlserver://hostNameOrIP:1433;user=UserName;password=*****;database=databaseName");





MS SQL 2005 的JDBC語法:
123
 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
 
Connection conn=DriverManager.getConnection("jdbc:sqlserver://hostNameOrIP:1433;user=UserName;password=*****;database=databaseName");





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

語法:

12
 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

語法:

12
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@host:port:databse","user","password");





Sybase

Driver: JConnect (JDBC 2.0 請使用5.5)

語法:
12345
 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

語法:

12
Class.forName("org.postgresql.Driver"); 
Connection con=DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");





Informix

Driver:com.informix.jdbc.IfxDriver

語法:

1234567
 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 Files\IBM\Client Access\jt400\lib
找到 driver 檔案 jt400.zip,並更改副檔名成為 jt400.jar

語法
123
 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"); 




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
其他資訊:

* 尋找查詢JDBC Driver的地方: http://servlet.java.sun.com/products/jdbc/drivers

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
通常driver都已包成jar檔
將jar設定在CLASSPATH中,或者如果是寫JSP,Servel可以將這些jar放到
使用的container中的lib資料夾底下
詳細內容就請大家自行去各家網站看看介紹
有很多文件可以看

good luck

koji

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

更新記錄:
2006.03.02 - 更新 Sybase JDBC Driver 下載網址
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics