我在连接SQL Server数据库时遇到以下异常。
INFO | jvm 1 | 2014/08/24 14:03:41 | SEVERE: [EXCEPTION].[com.datasweep.plantops.datamgt.exception.DataMgtException]: PlantOps.DataMgt: [Error initializing site 112 with guid 91799598AD9C4290BB3F5F5EF58D9ABC][Failed to connect: sql:type4:dbmesprod112:dsActive112:deanza:******] CASCADING: com.microsoft.sqlserver.jdbc.SQLServerException: Read timed out ClientConnectionId:f9c1a8c4-326a-4945-a166-e0c906bfe4e5
INFO | jvm 1 | 2014/08/24 14:03:41 | EXCEPTION: com.microsoft.sqlserver.jdbc.SQLServerException: Read timed out ClientConnectionId:f9c1a8c4-326a-4945-a166-e0c906bfe4e5
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1654)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1789)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:1424)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1319)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
INFO | jvm 1 | 2014/08/24 14:03:41 | at java.sql.DriverManager.getConnection(DriverManager.java:582)
INFO | jvm 1 | 2014/08/24 14:03:41 | at java.sql.DriverManager.getConnection(DriverManager.java:207)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.datasweep.common.db.agent.DBConnectionFactory.open(Unknown Source)
INFO | jvm 1 | 2014/08/24 14:03:41 | at com.datasweep.common.db.agent.DBConnectionFactory.openConnection(Unknown Source)
我尝试搜索Google的例外情况,但我没有收到任何有用的消息。
有人可以帮我解释为什么会发生异常?如何解决错误?
以下是连接代码:
public static DBConnection openConnection(String dataSourceReferenceName)
throws Exception
{
DataSource ds = lookupDataSource(dataSourceReferenceName);
Connection con = ds.getConnection();
Object[] serverInfo = getServerInfo(
dataSourceReferenceName,
con);
DBConnection dbConn = new DBConnection(
con,
((Integer) serverInfo[0]).intValue(),
(String) serverInfo[1]);
dbConn.setDataSourceJNDIName(dataSourceReferenceName);
return dbConn;
}