连接到SQLServer时出现JDBC错误

时间:2013-01-09 06:07:40

标签: java jdbc

在我的程序中使用JDBC连接我收到以下异常。我使用的是jdk1.6.0_25。

例外:

com.microsoft.sqlserver.jdbc.TDSChannel enableSSL WARNING: TDSChannel ( ConnectionID:1 TransactionID:0x0000000000000000) SSL handshake failed: RSA premaster secret error com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: RSA premaster secret error.
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(Unknown    Source) 
at com.microsoft.sqlserver.jdbc.TDSChannel.throwSSLConnectionFailed(Unknown    Source) 
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(Unknown    Source) 
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown    Source) 
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(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(Unknown Source) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at com.exterro.db.Dummy.main(Dummy.java:22) 
The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: RSA premaster secret error.

1 个答案:

答案 0 :(得分:1)

我遇到了与java 8,SQL server 2008,sqlserver驱动程序4.2相同的问题 在对使用带有该sqldriver的java 7进行主要/次要异常的其他投诉之后 似乎问题是因为(正如有人所说)sql server数据库在网络上与我运行代码的网络不同。第一个网络是172.x.x.x,第二个网络是15.x.x.x
由jtds驱动程序替换sqlserver驱动程序就像一个魅力,感谢下面的线程中的pepole
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a36ea16c-cc78-4054-bd02-dd637b1e9a81/warning-tdschannel-when-attempting-to-connect?forum=sqldataaccess