在我的 webapp 中,我经常遇到异常
org.hibernate.util.JDBCExceptionReporter: SQL Error: 17002, SQLState: 08006
14 Sep 2013 12:19:10,927 [ERROR] org.hibernate.util.JDBCExceptionReporter: IO Error: Connection reset
14 Sep 2013 12:19:10,927 [ERROR] could not load an entity: [EntityName]
nested exception is org.hibernate.exception.JDBCConnectionException: could not load an entity: [EntityName]
...
14 Sep 2013 12:19:10,930 [WARN] (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0) com.mchange.v1.db.sql.StatementUtils: Statement close FAILED.
java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.PhysicalConnection.needLine(PhysicalConnection.java:5389)
at oracle.jdbc.driver.OracleStatement.closeOrCache(OracleStatement.java:1578)
at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:1563)
at oracle.jdbc.driver.OracleStatementWrapper.close(OracleStatementWrapper.java:94)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.close(OraclePreparedStatementWrapper.java:80)
at com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.synchronousDestroyStatement(GooGooStatementCache.java:413)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.closeAll(GooGooStatementCache.java:351)
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeAllCachedStatements(NewPooledConnection.java:673)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:543)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
我尝试更改 C3P0 配置,但没有帮助
这是我当前的配置:
checkoutTimeout 10000
idleConnectionTestPeriod 0
initialPoolSize 10
maxIdleTime 28800
maxPoolSize 20
minPoolSize 8
numHelperThreads 5
testConnectionOnCheckin true
相关代码:简单调用HibernateTemplate的get方法
Object result = getHibernateTemplate().get(entityClass, id);
return (T) result;