Java 驱动程序无法使用安全套接字层 (SSL) 加密与 SQL Server 建立安全连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18620869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption
提问by Mojtaba Mahamed
I used this code to create a connection to SQL Server.
我使用此代码创建到 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
com.microsoft.sqlserver.jdbc.SQLServerException:驱动程序无法通过使用安全套接字层 (SSL) 加密建立到 SQL Server 的安全连接。错误:“套接字已关闭”。ClientConnectionId:5975fad5-8f8d-496a-a2bb-bff3a8d1a755
Can anybody help me? Thanks in advance
有谁能够帮助我?提前致谢
采纳答案by Ria
Check out this Microsoft JDBC Blogpost:
查看此Microsoft JDBC 博客文章:
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:
为了解决 SQLServer 的 SSL 问题(特别是对于 android 客户端:不幸的是,JDBC 驱动程序无法在 Android 操作系统中有效使用)尝试使用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)
jTDS
是用于 Microsoft SQL Server(6.5、7、2000、2005、2008 和 2012)的开源 100% 纯 Java(类型 4)JDBC 3.0 驱动程序
回答by granadaCoder
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
你在 Windows 机器上吗? 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.
下载并尝试在代码之外与您的服务器通信。端口查询工具将在代码之外显示它是否是防火墙(或类似)问题。