SANN3
SANN3

Reputation: 10109

JDBC error while connecting to SQLServer

Using JDBC connection in my program i am getting the following exception. I am using jdk1.6.0_25.

Exception:

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.

Upvotes: 1

Views: 15721

Answers (1)

Hasnaa Ibraheem
Hasnaa Ibraheem

Reputation: 1140

I faced the same issue with java 8, SQL server 2008, sqlserver driver 4.2
After having other complaint about major/ minor exception for using java 7 with that sqldriver
It seems that the issue was because (as someone stated) the sql server database was in network different from the the network from which I run the code.. the first network was 172.x.x.x and the second was 15.x.x.x
Replacing sqlserver driver by jtds driver worked like a charm, thanks to pepole in below thread
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a36ea16c-cc78-4054-bd02-dd637b1e9a81/warning-tdschannel-when-attempting-to-connect?forum=sqldataaccess

Upvotes: 1

Related Questions