我正在使用 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>
请帮忙。