我正在尝试从Java代码连接到Microsoft SQL服务器,该代码位于将在Webspehere 7服务器中运行的动态项目中。
below is my java code:
{
Connection conn = null;
System.out.println(System.getProperty("java.version"));
System.out.println(ManagementFactory.getRuntimeMXBean().getVmVersion());
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String dbURL = "jdbc:sqlserver://IP:51433;database=SCB_Recon_04032017";
String user = "uName";
String pass = "password";
conn = DriverManager.getConnection(dbURL, user, pass);
}
注意:当我将此作为java应用程序(独立运行java类)运行时,连接正确建立。但是当我在webspehere 7服务器上运行时,我会遇到异常。
{[21/6/17 16:41:07:170 IST] 0000001c SystemErr R com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed.".
[21/6/17 16:41:07:171 IST] 0000001c SystemErr R at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)
[21/6/17 16:41:07:171 IST] 0000001c SystemErr R at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1412)
[21/6/17 16:41:07:171 IST] 0000001c SystemErr R at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1058)
[21/6/17 16:41:07:172 IST] 0000001c SystemErr R at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
[21/6/17 16:41:07:172 IST] 0000001c SystemErr R at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
[21/6/17 16:41:07:172 IST] 0000001c SystemErr R at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
[21/6/17 16:41:07:173 IST] 0000001c SystemErr R at java.sql.DriverManager.getConnection(DriverManager.java:419)
[21/6/17 16:41:07:173 IST] 0000001c SystemErr R at java.sql.DriverManager.getConnection(DriverManager.java:467)
[21/6/17 16:41:07:173 IST] 0000001c SystemErr R at com.eeft.scbfileupload.sql.connection.JdbcSQLServerConnection.getConnection(JdbcSQLServerConnection.java:31)
[21/6/17 16:41:07:174 IST] 0000001c SystemErr R at com.eeft.scbfileupload.api.ScbFileUploadAPIBase.getAllTemplateTypesList(ScbFileUploadAPIBase.java:23)
[21/6/17 16:41:07:175 IST] 0000001c SystemErr R at com.eeft.scbfileupload.bo.ScbFileUploadBO.getAllTemplateTypesList(ScbFileUploadBO.java:20)
[21/6/17 16:41:07:184 IST] 0000001c SystemErr R at com.eeft.scbfileupload.servlet.SCBFileUploadMainServlet.doGet(SCBFileUploadMainServlet.java:35)
[21/6/17 16:41:07:184 IST] 0000001c SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
[21/6/17 16:41:07:186 IST] 0000001c SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
[21/6/17 16:41:07:186 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1700)
[21/6/17 16:41:07:187 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:970)
[21/6/17 16:41:07:187 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:508)
[21/6/17 16:41:07:189 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
[21/6/17 16:41:07:189 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3994)
[21/6/17 16:41:07:189 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
[21/6/17 16:41:07:190 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945)
[21/6/17 16:41:07:191 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
[21/6/17 16:41:07:191 IST] 0000001c SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
[21/6/17 16:41:07:191 IST] 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
[21/6/17 16:41:07:191 IST] 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:516)
[21/6/17 16:41:07:192 IST] 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:307)
[21/6/17 16:41:07:198 IST] 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:278)
[21/6/17 16:41:07:199 IST] 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[21/6/17 16:41:07:201 IST] 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[21/6/17 16:41:07:201 IST] 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
[21/6/17 16:41:07:202 IST] 0000001c SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[21/6/17 16:41:07:202 IST] 0000001c SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[21/6/17 16:41:07:202 IST] 0000001c SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
[21/6/17 16:41:07:202 IST] 0000001c SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
[21/6/17 16:41:07:203 IST] 0000001c SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
[21/6/17 16:41:07:203 IST] 0000001c SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
[21/6/17 16:41:07:203 IST] 0000001c SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1662)
}
答案 0 :(得分:1)
IBM WebSphere Application Server中默认启用SSLv3。 These fixes将完全禁用SSLv3。
此外,如果您不想在WebSphere上禁用SSLv3支持,则可以下载Microsoft SQLJDBC driver hotfix以更正SSL工作。在这种情况下你需要configure MSSQL to enable SSL。
有关其他信息,请参阅here。