1
votes

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.

1
I don't see anything in the code you provided specifying SSL.Neo
What PORT are you using?Neo
5081 is the port what i using to connect.Ivan Fontalvo
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.Gord Thompson
@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.)Gord Thompson

1 Answers

1
votes

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.