2

我将 Glassfish 和 Toplink 与 MS-SQL-Server 一起使用,因此 sqljdbc4.jar 用于连接到数据库。当数据库不可用(数据库服务器关闭)时,CPU 使用率上升到 100%,Glassfish 继续尝试永远连接。我的日志很快填满了以下消息:

FINE: TDSChannel (ConnectionID:7) read failed:Connection reset
FINE: *** SQLException:ConnectionID:7 com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset Connection reset
FINE: com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1355)com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1532)com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:3274)com.microsoft.sqlserver.jdbc.TDSReader.nextPacket(IOBuffer.java:3227)com.microsoft.sqlserver.jdbc.TDSReader.ensurePayload(IOBuffer.java:3203)com.microsoft.sqlserver.jdbc.TDSReader.peekTokenType(IOBuffer.java:3420)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:50)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:39)com.microsoft.sqlserver.jdbc.SQLServerStatement.processExecuteResults(SQLServerStatement.java:1064)com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.processResponse(SQLServerPreparedStatement.java:345)com.microsoft.sqlserver.jdbc.TDSCommand.close(IOBuffer.java:4111)com.microsoft.sqlserver.jdbc.SQLServerStatement.discardLastExecutionResults(SQLServerStatement.java:99)com.microsoft.sqlserver.jdbc.SQLServerStatement.closeInternal(SQLServerStatement.java:592)com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.closeInternal(SQLServerPreparedStatement.java:170)com.microsoft.sqlserver.jdbc.SQLServerStatement.close(SQLServerStatement.java:604)com.sun.gjc.spi.ManagedConnectionFactory.isValidByTableQuery(ManagedConnectionFactory.java:397)com.sun.gjc.spi.ManagedConnectionFactory.isValid(ManagedConnectionFactory.java:297)com.sun.gjc.spi.ManagedConnectionFactory.getInvalidConnections(ManagedConnectionFactory.java:246)com.sun.enterprise.resource.AbstractConnectorAllocator.getInvalidConnections(AbstractConnectorAllocator.java:99)com.sun.enterprise.resource.AbstractResourcePool.removeInvalidResources(AbstractResourcePool.java:1535)com.sun.enterprise.resource.AbstractResourcePool.removeInvalidAndIdleResources(AbstractResourcePool.java:1515)com.sun.enterprise.resource.AbstractResourcePool.resizePool(AbstractResourcePool.java:1448)com.sun.enterprise.resource.AbstractResourcePool$Resizer.run(AbstractResourcePool.java:1610)java.util.TimerThread.mainLoop(Timer.java:512)java.util.TimerThread.run(Timer.java:462)

有没有办法为与数据库的连接设置重试限制,或者在连接重试之间设置暂停超时?

如何让 Glassfish 抛出异常而不是尝试永远连接?

4

2 回答 2

0

我们追踪到了,这似乎是微软在 sqljdbc4.jar 中的一个错误:

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=483322

于 2009-08-19T08:58:02.383 回答
0

GlassFish 的 HADB 版本为 MS SQL 提供免费的 DataDirect JDBC 驱动程序,可以处理连接重置和关闭

于 2009-12-04T17:21:05.627 回答