The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption

你。 提交于 2019-11-26 11:27:16

问题


I used this code to create a connection to SQL Server.

String connectionUrl = \"jdbc:sqlserver://IP:1433;\" +
        \"databaseName=db;user=db;password=pwd\";
    Connection con = null;
  try {
     // Establish the connection.
     Class.forName(\"com.microsoft.sqlserver.jdbc.SQLServerDriver\");
     con = DriverManager.getConnection(connectionUrl);
        return \"true\";
  }

  // Handle any errors that may have occurred.
  catch (Exception e) {
     e.printStackTrace();
  }

but i got this 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: \"Socket closed\". ClientConnectionId:5975fad5-8f8d-496a-a2bb-bff3a8d1a755

Can anybody help me? Thanks in advance


回答1:


Check out this Microsoft JDBC Blog post:

  • The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption.

for resolve SSL problems with SQLServer (specially for android clients:JDBC driver can not be used effectively in the Android OS on unfortunately) try to using jDTS:

jTDS is an open source 100% pure Java (type 4) JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000, 2005, 2008 and 2012)




回答2:


Is it

databaseName=MyDB

or

database=MyDB

?

Try the latter.

Are you on a Windows Machine? http://www.microsoft.com/en-us/download/details.aspx?id=24009

Download that and try to talk to your server outside of your code. The port query tool will show you if its a firewall (or similar) issue, outside of the code.



来源:https://stackoverflow.com/questions/18620869/the-driver-could-not-establish-a-secure-connection-to-sql-server-by-using-secure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!