1

I am trying to connect to SQL Server 2014 with Java 7 via JDBC driver and the error that the app throws is :

The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server returned an incomplete response. The connection has been closed."

My code is:

driver ="com.microsoft.sqlserver.jdbc.SQLServerDriver";
url ="jdbc:sqlserver://Ip:port;databasename=xxx";
user = "xxx";
pass = "xxx";
Class.forName(driver);
connection = DriverManager.getConnection(url, user, pass);

I downloaded the ODBC driver package from MSDN and have tried using each of the following in turn: sqljdbc.jar, sqljdbc4.jar, sqljdbc41.jar, and sqljdbc42.jar, but I got the same error each time.

7
  • 1
    I don't see anything in the code you provided specifying SSL. Commented Nov 1, 2016 at 15:22
  • What PORT are you using? Commented Nov 1, 2016 at 15:23
  • 5081 is the port what i using to connect. Commented Nov 1, 2016 at 15:25
  • If by "used all of [them]" you mean that you put all four JAR files in your CLASSPATH/Build_Path then try removing three of them and just leaving sqljdbc4.jar. That one works for me when connecting to a SQL Server instance that requires an SSL connection. Commented Nov 1, 2016 at 15:35
  • 1
    @IvanFontalvo - Try creating a simple Java console application to connect to the SQL Server with sqljdbc4.jar. If that fails then your problem is more fundamental (e.g., SQL Server settings, network configuration, etc.). If it succeeds, then you'll need to dig deeper into the details of your Tomcat configuration. (Also, remember to include @UserName when replying to a comment.) Commented Nov 1, 2016 at 16:11

1 Answer 1

1

I resolve the issue using JTDS as driver manager , my code now is :

driver ="net.sourceforge.jtds.jdbc.Driver;
url ="jdbc:jtds:sqlserver://Ip:port;databasename=xxx";
user = "xxx";
pass = "xxx";
Class.forName(driver);
connection = DriverManager.getConnection(url, user, pass);

and i added the lib jtds1.5.1 in my classpath.

Sign up to request clarification or add additional context in comments.

2 Comments

There is no jtds1.5.1 binary at the link you provided.
Surprisingly JTDS 1.3 (last stable version) also works to resolve this error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.