我正在使用c3p0进行连接池,并且面对大型数据集的“已关闭连接”错误。我希望我的交易是原子的,并且运行几乎最多2个小时。
对于大型数据集,处理时间约为40-45分钟。当我尝试将这些数据保存在数据库中时,我会按以下顺序获得异常:
[WARN] [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
[WARN] [c3p0] Another error has occurred [ java.sql.SQLRecoverableException: Closed Connection ] which will not be reported to listeners!
[ERROR] org.hibernate.transaction.JDBCTransaction: Could not toggle autocommit
java.sql.SQLRecoverableException: Closed Connection
[ERROR] org.hibernate.transaction.JDBCTransaction: JDBC rollback failed
[ERROR] org.springframework.transaction.interceptor.TransactionInterceptor: Application exception overridden by rollback exception.
我尝试过多次尝试解决方案,并尝试相应地更新我的配置。 这是我的C3P0配置:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${...}" />
<property name="jdbcUrl" value="${...}" />
<property name="user" value="${...}" />
<property name="password" value="${...}" />
<property name="initialPoolSize" value="2" />
<property name="minPoolSize" value="2" />
<property name="maxPoolSize" value="50" />
<property name="maxIdleTime" value="6000" />
<property name="maxIdleTimeExcessConnections" value="1800" />
<property name="idleConnectionTestPeriod" value="3600" />
<property name="checkoutTimeout" value="60000" />
<property name="acquireRetryAttempts" value="0" />
<property name="acquireRetryDelay" value="1000" />
<property name="numHelperThreads" value="1" />
<property name="preferredTestQuery" value="SELECT 1 FROM DUAL" />
</bean>
请帮忙。