JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » JDBC/SQL討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
話題鎖定
該話題已被鎖定 - anthonychen , 2010-12-07 20:36
如果您尚不清楚該話題被鎖定的原因,請參考論壇規則以及本版公告或者聯系本版版主。
本主題所含的標籤
作者 各家JDBC driver的現行版本及使用語法 ver.20080708 [精華]
koji

秒速5センチメートル

站長

發文: 8415
積分: 19
於 2003-06-11 15:01 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
有鑒於許多版友對於尋找JDBC driver或者如何使用driver常常發問,
在這邊我簡單整理一下比較代表性的driver跟使用方式.

Microsoft SQL Server series (6.5, 7.x, 2000, 2005) and Sybase 10

Driver Name: jTDS
URL: http://jtds.sourceforge.net
Download: http://sourceforge.net/project/showfiles.php?group_id=33291

語法:

1
2
3
4
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");


Driver Name: Microsoft SQL Server JDBC Driver
Download : http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx
Microsoft SQL Server 2005 JDBC Driver 1.2
SQL Server 2000 Driver for JDBC Service Pack 3

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


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


MySQL

Driver Name: Connector/J
Download : http://www.mysql.com/downloads/connector/j

語法:

1
2
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://host:port/database","user","password");


Oracle

Driver Name: Oracle JDBC Drivers
Download : http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html

語法:

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


Sybase

Driver Name: jConnect
Download: http://www.sybase.com/products/allproductsa-z/softwaredeveloperkit/jconnect
語法:
1
2
3
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

語法:

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


Informix

Driver:com.informix.jdbc.IfxDriver

語法:

1
2
3
4
5
6
7
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

語法
1
2
3
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://developers.sun.com/product/jdbc/drivers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
通常driver都已包成jar檔
將jar設定在CLASSPATH中,或者如果是寫JSP,Servel可以將這些jar放到
使用的container中的lib資料夾底下
詳細內容就請大家自行去各家網站看看介紹
有很多文件可以看

good luck

koji

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

更新記錄:
2006.03.02 - 更新 Sybase JDBC Driver 下載網址
2010.12.07 - 更新失效的 JDBC Driver 網址


anthonychen edited on 2010-12-07 20:36
reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
ROACH





發文: 64
積分: 0
於 2003-06-14 12:36 user profilesend a private message to usersend email to ROACHreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
這邊我提供IBM AS400主機在用的JDBC語法

有裝V4R4以上版本的Client Access Express
可以在
C:\Program Files\IBM\Client Access\jt400\lib
找到該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");


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
htcim



發文: 0
積分: 0
於 2003-06-24 15:10 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
真的是太感謝 koji 的提供及整理Big Smile
但是不好意思還有一個問題
就是我DOWNLOAD第一個 for MS-SQL的DRIVER回來用
也放進lib夾裡,也修改了classpath (因為之前的driver到期了 >.<Wink
run之後發生網頁跑很久很久....
最後show出error msgDisapproved

org.apache.jasper.JasperException: Unknown packet type 0x0
Packet header is
0000 00 00 00 00 00 00 00 00 |........|

請問這是什麼意思呢?謝謝Big Smile

備註:
String $dbuser="sa";
String $dbpwd = "";
String $url = "jdbc:jtds:sqlserver://localhost:8080/我的資料庫名稱";

Class.forName("net.sourceforge.jtds.jdbc.Driver");
con = DriverManager.getConnection($url, $dbuser, $dbpwd);


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
alanting

Alan Ting



發文: 200
積分: 3
於 2003-06-24 16:39 user profilesend a private message to usersend email to alantingreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我是沒用過那個for ms-sql的jdbc,我是用M牌自家出的for sql2k的jdbc,如果你是用sql2k的話,可以去下載,不過下載點忘了,請去M家搜尋。

reply to postreply to post
重新學習...拜讀各位大大的巨作中..
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
htcim



發文: 0
積分: 0
於 2003-06-24 17:46 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝alanting回覆
可以請問M家的網址?還是就是這裡呢?
....m....抱歉,我搜尋不到說,可否請你再說清楚一點
關於Where is M家好嗎?
謝謝


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
alanting

Alan Ting



發文: 200
積分: 3
於 2003-06-24 17:51 user profilesend a private message to usersend email to alantingreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Microsoft = M <==習慣了
http://www.microsoft.com/sql/ <==在這邊找找...


reply to postreply to post
重新學習...拜讀各位大大的巨作中..
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
alanting

Alan Ting



發文: 200
積分: 3
於 2003-06-24 18:05 user profilesend a private message to usersend email to alantingreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我已經抓下來了 不知道誰可以提供空間 我把檔案放上去?

reply to postreply to post
重新學習...拜讀各位大大的巨作中..
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:alanting]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-06-24 18:09 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
alanting wrote:
我已經抓下來了 不知道誰可以提供空間 我把檔案放上去?


jute 有限制一mb ..
我想 .. 提供url .. 大家去下載就好了


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
alanting

Alan Ting



發文: 200
積分: 3
於 2003-06-25 09:53 user profilesend a private message to usersend email to alantingreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
http://www.microsoft.com/sql/downloads/jdbcregister.asp
需要微軟出的jdbc請到這個網址
不過你要填寫passport的帳號,有用msn的人應該都知道...
這個好像是新版的。htcim 提了我去看看才發現的,謝謝htcim 囉^^


reply to postreply to post
重新學習...拜讀各位大大的巨作中..
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
fanny





發文: 52
積分: 0
於 2003-06-25 12:48 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
那我提供一下db2的語法啦!
以前都以為db2 很少人用,但去上班後db2還好多公司在用!
所以就要會啦!
db2的driver 去下載就可以啦!
如果你問我db2好不好用哦! 我覺得還是比microsoft的好啦!!

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
//載入驅動程式類別
con = DriverManager.getConnection ("jdbc:db2:別名","帳號","密碼");
//建立資料庫連線


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
htcim



發文: 0
積分: 0
於 2003-06-26 10:49 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝各位前輩指導,真的很感激~ ^_^

但我下載該頁面上的setup.exe(for windows)後-->Double click setup.exe

---->設定CLASSPATH為
.;c:\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;c:\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;c:\Microsoft SQL Server 2000 Driver for JDBC
\lib\mssqlserver.jar

----->
1
2
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:8080","username","secret"); 

================Error msg===================
description
The server encountered an internal error () that prevented it from fulfilling this request.

exception
org.apache.jasper.JasperException: com.microsoft.jdbc.sqlserver.SQLServerDriver

可否再麻煩各位前輩指導一下?謝謝


anthonychen edited on 2004-06-15 14:28
reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
alanting

Alan Ting



發文: 200
積分: 3
於 2003-06-26 11:51 user profilesend a private message to usersend email to alantingreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的疑問啦,SQL預設不是8080port吧 你有改嗎?
上面只是問題,不是重點,你去下載 for unix版本,可以直接用winrar解開,裡面可以找到lib的資料夾 我想那個對你比較好使用。可以把.jar抓出來放到你想放的地方.


reply to postreply to post
重新學習...拜讀各位大大的巨作中..
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:htcim]
jini

SoftLeader Taiwan

版主

發文: 1266
積分: 23
於 2003-06-26 12:05 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
htcim wrote:
謝謝各位前輩指導,真的很感激~ ^_^

但我下載該頁面上的setup.exe(for windows)後-->Double click setup.exe

---->設定CLASSPATH為
.;c:\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;c:\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;c:\Microsoft SQL Server 2000 Driver for JDBC
\lib\mssqlserver.jar

----->
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:8080","username","secret");

================Error msg===================
description
The server encountered an internal error () that prevented it from fulfilling this request.

exception
org.apache.jasper.JasperException: com.microsoft.jdbc.sqlserver.SQLServerDriver

可否再麻煩各位前輩指導一下?謝謝


M$ SQL Server default port is 1433
u could try it or Edit Server Properties to find the connect port

and Why not use the jtds ( http://jtds.sourceforge.net )
to replace the MS SQL JDBC Driver ...

DriverName = "net.sourceforge.jtds.jdbc.Driver";
DBUrl = "jdbc:jtds:sqlserver://localhost:1433";


reply to postreply to post
My fans-page on Facebook (welcome join it )
https://www.facebook.com/EnterpriseJava
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
htcim



發文: 0
積分: 0
於 2003-06-26 14:21 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
多謝alanting跟jini 及各位前輩
終於可以了Embaressed
我想可能是我自己有的地方太粗枝大葉了,以致都還不知道之前到底是錯在哪..
而我就再嘗試一次 jtds ,結果.....ok啦~~~好高興!

把我的做法提供出來,以供參考

====================sql.inc======================
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<%@ page import="java.sql.*" %>
<%
Connection con = null;
Statement statement1 = null;
Statement statement2 = null;
Statement statement3 = null;
Statement statement4 = null;
Statement statement5 = null;
 
Class.forName("net.sourceforge.jtds.jdbc.Driver");
con = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433","sa",""); 
 
statement1 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
statement2 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
statement3 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
statement4 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
statement5 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
 
con.setCatalog("我的資料庫名");
%>


===================classpath=====================
.;c:\j2sdk1.4.0_03\lib\tools.jar;c:\j2sdk1.4.0_03\lib\jtds-0.5.1.jar

=============================================

以上供參考,也很感謝很多指導的人,謝謝


browser edited on 2003-11-13 22:33
reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
htcim



發文: 0
積分: 0
於 2003-06-27 15:02 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
不好意思,剛剛突然發現....jtds是type4
而查了microsoft自家出的SQL Server 2000 Driver for JDBC,沒看到它是type幾,可否請知道的人告訴我?謝謝

PS:因為我目前需要用type3bowwow


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:htcim]
JiaYun



版主

發文: 761
積分: 9
於 2003-06-27 15:07 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
這裡可以搜

http://servlet.java.sun.com/products/jdbc/drivers


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:htcim]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-06-27 15:09 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
htcim wrote:
不好意思,剛剛突然發現....jtds是type4
而查了microsoft自家出的SQL Server 2000 Driver for JDBC,沒看到它是type幾,可否請知道的人告訴我?謝謝

PS:因為我目前需要用type3bowwow


type 4


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
jini

SoftLeader Taiwan

版主

發文: 1266
積分: 23
於 2003-06-28 06:31 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
IBM DB2 如果是不同機器 AppServer <-> DBServer

DriverName = "COM.ibm.db2.jdbc.net.DB2Driver"
DBUrl = "jdbc:db2:://[ip]:[port]/[dbname]"

Devil 用 COM.ibm.db2.jdbc.app.DB2Driver 搞了一個下午.... 失敗


jini edited on 2003-06-28 07:44
reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
alanting

Alan Ting



發文: 200
積分: 3
於 2003-06-29 02:18 user profilesend a private message to usersend email to alantingreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你AppServer跟DBServer中間有Firewall嗎?

reply to postreply to post
重新學習...拜讀各位大大的巨作中..
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
weber



發文: 0
積分: 0
於 2003-07-04 16:30 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
有沒有FOR DBASE或*.DBF的JDBC語法

reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:weber]
ray_linn

什么都不懂的小白

版主

發文: 540
積分: 10
於 2003-07-18 22:11 user profilesend a private message to usersend email to ray_linnreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
weber wrote:
有沒有FOR DBASE或*.DBF的JDBC語法

JDBC-ODBC


reply to postreply to post
飞翔的候鸟
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
chrischang





發文: 166
積分: 2
於 2003-07-29 07:55 user profilesend a private message to usersend email to chrischangreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
就是先用 ODBC 設定一個資料來源到你的 .DBF 檔案 , 然後再利用 JDBC to ODBC Driver 就可以連到了 .

reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
test123



發文: 0
積分: 0
於 2003-07-30 15:51 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
請問一下.那 informix 的話.
要怎麼設定呢??


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
tenyi





發文: 6
積分: 0
於 2003-08-21 21:38 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
請問各位大大,小弟之前用MySQL都用mm的JDBC,現在這個有啥不同呢?
快速?正確?已經兩年沒用MySQL,都不知連JDBC都有新的...
另外SQLServer JDBC不用M$的有啥好處呢?jtds的特點在那呢?
因為小弟目前用M$的JDBC還沒有遇到問題。

謝謝 Smile


reply to postreply to post
作者 Re:各家JDBC driver的現行版本及使用語法 ver.20030611 [Re:koji]
robinjam





發文: 34
積分: 0
於 2003-08-29 14:06 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
informix的寫法
1
2
3
4
5
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);


anthonychen edited on 2004-06-15 14:38
reply to postreply to post
go to first page go to previous page  1   2  go to next page go to last page
» JWorld@TW »  JDBC/SQL討論區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8