使用jTDS连接到SQL Server 2012会抛出IOException; MS SQL驱动程序有效

时间:2016-04-19 18:04:05

标签: sql-server jdbc jtds

以下代码使用jTDS驱动程序(1.3.1):

DriverManager.getConnection("jdbc:jtds:sqlserver://anIpAddress;databaseName=aDatabase", "user", "pass")

结果:

java.sql.SQLException: I/O Error: DB server closed connection.
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2481)
    at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:632)
    at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:371)
    at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.seasset.crd.test.TestDb.main(TestDb.java:20)
Caused by: java.io.IOException: DB server closed connection.
    at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:852)
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:731)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2368)

但是,使用MS SQL驱动程序(4.2)的此代码无例外地工作:

DriverManager.getConnection("jdbc:sqlserver://anIpAddress;databaseName=aDatabase", "user", "pass")

我正在尝试连接到SQL Server 2012数据库。注意:用户具有对数据库的只读访问权限。我无权更改SQL Server 2012上的任何配置。我尝试使用相同的代码连接到SQL Server 2005数据库,在这种情况下,Microsoft和jTDS驱动程序都可以正常工作。

如何使用jTDS毫无例外地连接到SQL Server 2012数据库?

0 个答案:

没有答案