【发布时间】:2017-12-24 15:02:32
【问题描述】:
我已经搜索了很长时间,但还没有找到解决方案,我目前正在尝试建立与 SQL Server 的连接
Connection con = ds.getConnection
但我遇到了这个异常:
Cannot create PoolableConnectionFactory (The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: Broken pipe ClientConnectionId:8fb783f6-2790-44e9-b459-18238edd23ff"
这是由于驱动程序无法建立 SSL 连接。
我已经能够验证我能够 ping 并查看数据库而没有任何问题,但不知何故仍然出现此错误。
列出的原因是:
com.microsoft.sqlserver.jdbc.SQLServerException (The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: Broken pipe ClientConnectionId:8fb783f6-2790-44e9-b459-18238edd23ff"
同上原因,无法建立 SSL 连接。
在我列出的 context.xml 中:
<Resource name="jdbc/sqlazure"
auth="Container"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
type="javax.sql.DataSource"
maxIdle="30"
username="username"
password="password
url="jdbc:sqlserver://axpert.database.windows.net:1433;database="db";encrypt=true;trustServerCertificate=false;hostNameInCertificate="database";loginTimeout=30"
removeAbandonedTimeout="30"
logAbandoned="true" />
我正在像这样获取数据源:
InitialContext ic = new InitialContext();
ds = (DataSource)ic.lookup("java:comp/env/jdbc/sqlazure");
所以 encrypt 也设置为 true。我之前没有看到这个问题,我唯一能想到的是我最近确实安装了 Android Studio,不确定这是否会以某种方式弄乱 Java 设置?
我正在使用 2017 年 6 月的 Eclipse Oxygen、Java 1.8.0_141、Tomcat 8.5
【问题讨论】:
标签: java sql-server azure azure-sql-database azure-web-app-service