发生以下异常时,这意味着环境出现问题,特别是如果这些异常仅发生在具有大量用户的生产环境中,并且在具有正常用户数的测试环境中没有任何问题。
1. Could not open connection: org.hibernate.exception.GenericJDBCException: Could not open connection.
2. java.sql.SQLRecoverableException: Closed Connection.
3. java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
我的环境信息:
windows server 2012, oracle DB, jboss 7.1 application server and java application use hibernate 4 with c3p0 connection pools
我搜索了很多相关主题,我找到了许多有用的主题,但最有用的主题是这两个主题。 topic_1 topic_2
当我减少c3p0配置文件中的配置maxStatements时,我模拟了这种情况,但作为定义here的此参数的定义,它是c3p0的全局PreparedStatement缓存的大小。
我有以下问题:
我的c3p0-config如下:
<default-config>
<property name="checkoutTimeout">300</property>
<property name="idleConnectionTestPeriod">70</property>
<property name="initialPoolSize">50</property>
<property name="maxIdleTime">270</property>
<property name="maxPoolSize">500</property>
<property name="minPoolSize">50</property>
<property name="maxStatements">400</property>
<property name="maxStatementsPerConnection">0</property>
<property name="testConnectionOnCheckout">true</property>
<property name="testConnectionOnCheckin">true</property>
<property name="preferredTestQuery">SELECT 1 from dual</property>
<property name="acquireRetryAttempts">0</property>
<property name="acquireRetryDelay">1000</property>
<property name="breakAfterAcquireFailure">false</property>
<property name="unreturnedConnectionTimeout">270</property>
<property name="debugUnreturnedConnectionStackTraces">true</property>
</default-config>