--問題1:出現(xiàn)ClassNotFoundException,這個(gè)問題是由于你沒有把driver類放到你的classpath中,也就是說
你的程序找不到驅(qū)動(dòng)類,包括三個(gè)包:msutil.jar,msbase.jar,mssqlserver.jar
到微軟網(wǎng)站下載此驅(qū)動(dòng)到微軟官方網(wǎng)站下載 jdbc3,安裝后在C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib中可找到此三個(gè)驅(qū)動(dòng)
使用 Microsoft SQL Server 2000 JDBC 驅(qū)動(dòng)程序時(shí),您可能會(huì)遇到以下異常:
java.sql.SQLException:[Microsoft][SQLServer 2000 Driver for JDBC]Can't start a cloned connection while in manual transaction mode.
原因
在手工事務(wù)模式 (AutoCommit=false) 下,如果使用直接 (SelectMethod=direct) 模式,當(dāng)您嘗試對(duì)使用 JDBC 驅(qū)動(dòng)程序的 SQL Server 數(shù)據(jù)庫(kù)執(zhí)行多個(gè)語句時(shí),將會(huì)出現(xiàn)此問題。直接模式是該驅(qū)動(dòng)程序的默認(rèn)模式。
解決方案
當(dāng)您使用手工事務(wù)模式時(shí),必須將驅(qū)動(dòng)程序的 SelectMethod 屬性設(shè)置為 Cursor,或者確保您按照本文“更多信息”一節(jié)指定的方式在每個(gè)連接上只使用一個(gè)活動(dòng)語句。
配置實(shí)例(數(shù)據(jù)庫(kù)鏈接字符串,注意url)
driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=whm;SelectMethod=cursor
username=sa
password=sa
手動(dòng)寫的鏈接字符串
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=whm;SelectMethod=cursor","userName","password");
posted on 2007-01-10 20:24
滌生 閱讀(274)
評(píng)論(0) 編輯 收藏