0

I’ve been receiving the following 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: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:be8d9e1d-fff7-4310-ae77-03394c83f86b".

(More of the error at bottom of post) When trying to connect to a MSSQL database.

I’m using the following connection string:

jdbc:sqlserver://192.168.100.190:1433;databaseName=myDatabase;user=validUser;password=validPassword;encrypt=false;trustServerCertificate=false;sslProtocol=TLSv1;

I’ve tried variations of the connection string, essentially changing and omitting:

encrypt=false;trustServerCertificate=false;sslProtocol=TLSv1; 

I’ve tried different versions of the driver from:

https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-2017

all with the same results.

  • It is important to note that on some PC’s the application connects and works as expected but I have so far found no real differences between the PC’s or user accounts, no pattern really.
  • I’ve tried different versions of the JDK and different JRE’s, all give the same results. UPDATE: I have since found JRE 1.8.0_152 works in all my test cases
  • I’ve tried looking at logs on the servers and there are no entries in the SQL logs.
  • If I try a connection string with the wrong credentials, the error is exactly the same.
  • I’ve setup a test server and database, this works fine, as does one I setup in a Virtual Machine.
  • I can connect to said database using Navicat for example and have another application, writing in Visual Basic.Net that connects fine, so it would see that it is just something with this driver or java, but as I say, it does work on some PC’s and not others and of course works as expected in my test environment.

Any thoughts or suggestions would be greatly appreciated.

I’ve not provided any code, as I can replicate the exact same results using the example code provided here:

https://learn.microsoft.com/en-us/sql/connect/jdbc/step-3-proof-of-concept-connecting-to-sql-using-java?view=sql-server-2017

More detail on 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: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:be8d9e1d-fff7-4310-ae77-03394c83f86b".
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2670)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1837)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2257)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:623)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at database.DataBase.openConnection(DataBase.java:122)
    at jambuddylite.jblCoord.readSimex(jblCoord.java:387)
    at jambuddylite.jblCoord$2.run(jblCoord.java:314)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: SQL Server did not return a response. The connection has been closed. ClientConnectionId:be8d9e1d-fff7-4310-ae77-03394c83f86b
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:780)
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:836)
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:827)
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:1009)
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:997)
    at sun.security.ssl.InputRecord.readFully(Unknown Source)
    at sun.security.ssl.InputRecord.read(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1767)
    ... 11 more
plisken
  • 67
  • 1
  • 8
  • We’re you able to solve this ? If so could you please explain the fix – Meiyappan Kannappa Mar 29 '21 at 16:41
  • Meiyappan Kannappa I no longer update this project but did find the only solution for me was to have JRE 1.8.0_152 on the target machines, anything newer gave the error as above. – plisken Mar 30 '21 at 07:38

1 Answers1

0

check the port is open or not using on cmd or terminal

telnet 192.168.100.190 1433

and check the database name and credentials

and firewall there is some thing in firewall i think

and take a look here may help you

fathy elshemy
  • 481
  • 5
  • 18
  • fathy elshemy this was not the problem, the issue remains unresolved with all other JRE's that I have tried with exception to JRE 1.8.0_152 – plisken Jul 03 '20 at 08:28
  • @plisken I don't talk about JRE but about connectivity with your sql server this exception happened to me more than once and every time there was something in connectivity so my steps is about check connectivity with sql server and check you configurations too bro. – fathy elshemy Jul 03 '20 at 11:10