gpt4 book ai didi

java - 随机获取 JDBCConnectionException

转载 作者:行者123 更新时间:2023-11-30 09:17:49 25 4
gpt4 key购买 nike

在我的网络应用程序中,我经常遇到异常

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;

最佳答案

虽然听起来您已经尝试了很多,但如果您正在使用 testConnectionOnCheckin,您应该将它与一个短的、非零的 idleConnectionTestPeriod 结合起来。为了提高性能,您还应该设置一个 preferredTestQuery。

检查不可靠的连接测试是否是您的问题的最简单方法是从 testConnectionOnCheckin 切换到 testConnectionOnCheckout(并添加 preferredTestQuery 以最小化性能影响)。如果这解决了您的问题,那么您就知道您需要的是良好的连接测试,并且您可以切换回来并尝试使用 idleConnectionTestPeriod 的长度。如果 testConnectionOnCheckout 没有解决问题,那么它不太可能是连接测试问题。 testConnectionOnCheckout 是一个非常可靠的设置。

http://www.mchange.com/projects/c3p0-0.9.5-pre4/#simple_advice_on_connection_testing http://www.mchange.com/projects/c3p0-0.9.5-pre4/#configuring_connection_testing

关于java - 随机获取 JDBCConnectionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18801741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com