连接SQLServer时出现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.

我在java 8, SQL server 2008, sqlserver driver 4.2中遇到了同样的问题
在对使用sqldriver的java 7的主要或次要异常有其他抱怨之后
似乎这个问题是因为(如有人所说)sql server数据库在网络中不同于我运行代码的网络。第一个网络是172.x.x。第二个是15.x.x.x
通过jtds驱动程序替换sqlserver驱动程序工作得很好,感谢下面线程的人
https://social.msdn.microsoft.com/forums/sqlserver/en us/a36ea16c cc78 - 4054 - bd02 dd637b1e9a81/warning tdschannel -时-尝试- - connect?forum=sqldataaccess

最新更新