日期:2014-05-16  浏览次数:20471 次

java数据库驱动的问题
</pre></p><p><b>root cause</b> <pre>java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:sqlserver://192.168.138.81:1433;DatabaseName=Product, username = xxxx. Terminating connection pool. Original Exception: ------
com.microsoft.sqlserver.jdbc.SQLServerException: 不支持此服务器版本。目标服务器必须是 SQL Server 2000 或更高版本。
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
	at com.microsoft.sqlserver.jdbc.DBComms.Prelogin(Unknown Source)
	at com.microsoft.sqlserver.jdbc.DBComms.&lt;init&gt;(Unknown Source)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:185)
	at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:256)
	at com.jolbox.bonecp.BoneCP.&lt;init&gt;(BoneCP.java:305)
	at com.jolbox.bonecp.BoneCPDataSource.maybeInit(BoneCPDataSource.java:150)
	at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:112)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
	at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:210)
	at $Proxy11.toString(Unknown Source)

?

?? 前一段时间开发环境跑的好好的程序,到线上抛了异常,查找原因发现,开发环境用的数据库为sqlserver2005,线上库为sqlserver 2008,而开发用的驱动为 com.microsoft.sqlserver:sqlserver-jdbc:1.0 后来发现这个版本太低了,不支持sqlserver2008,因此升级了驱动解决了此问题 com.microsoft.sqlserver:sqlserver-jdbc:3.0

?

?? 特发此记录一下让我郁闷的sqlserver