请帮我。我对c3po感到困惑。在我的应用程序中,我使用的是休眠(作为 JPA 提供者)和 c3po。如果进行中的交易连接失败,我必须采取一些行动。当连接断开时,我抓住了
(javax.persistence.PersistenceException) javax.persistence.PersistenceException
org.hibernate.exception.GenericJDBCException:
Exception input/output: Connection reset by peer: socket write error
问:我能否确定只有在连接中断的情况下才会出现 GenericJDBCException(连接到数据库的问题(重新启动、网络问题、终止会话等))?换句话说,我需要知道保证异常是由于连接下降。阿列克谢。
我的配置
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.connection.autocommit" value="false"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.connection.provider_class" value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider"/>
<property name="hibernate.connection.autoReconnect" value="true"/>
<!--максимальное количество соединений в пуле-->
<property name="hibernate.c3p0.max_size" value="5"/>
<!--минимальный размер пула-->
<property name="hibernate.c3p0.min_size" value="1"/>
<property name="hibernate.c3p0.acquire_increment" value="1"/>
<!--как долго ждать, чтобы подтвердить соединение, т.е. не закрывать его, а, например, сделать запрос "select 1"-->
<property name="hibernate.c3p0.idle_test_period" value="30"/><!-- In seconds -->
<property name="hibernate.c3p0.max_statements" value="50"/>
<!--таймаут для с3p0-->
<property name="hibernate.c3p0.timeout" value="0"/>
<property name="hibernate.cache.use_second_level_cache" value="false"/>
<property name="hibernate.jdbc.batch_size" value="50"/>
<property name="hibernate.c3p0.checkoutTimeout" value="0"/>
<property name="hibernate.c3p0.preferredTestQuery" value="select 1 from dual"/>
<property name="hibernate.c3p0.testConnectionOnCheckout" value="true"/>
<property name="hibernate.c3p0.testConnectionOnCheckIn" value="true"/>
<property name="hibernate.c3p0.acquireRetryAttempts" value="0"/>
<property name="hibernate.c3p0.acquireRetryDelay" value="5000"/>
<property name="hibernate.c3p0.breakAfterAcquireFailure" value="false"/>