Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
642 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Check out this Microsoft JDBC Blog post:

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...