我正在尝试使用c3p0连接池上传图像(逐个)但我的jdbc类型4驱动程序(连接到mysql)一直在关闭连接。我已经看到mysql配置中的最大超时设置为300秒。这是我的持久性xml如何使用c3p0。
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
scope="singleton" destroy-method="close">
<property name="driverClass" value="...." />
<property name="jdbcUrl" value="...." />
<property name="user" value="....." />
<property name="password" value="...." />
<property name="initialPoolSize" value="10" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="5" />
<property name="autoCommitOnClose" value="false" />
</bean>
有人可以解释究竟是什么导致驱动程序隐式关闭连接。 另外,我该如何解决这个问题呢?
以下是我收到的错误消息:
19:01:45,504 WARN NewPooledConnection:486 - [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
19:01:45,505 WARN NewPooledConnection:487 - [c3p0] Another error has occurred [
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver. ] which will not be reported to listeners!
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver.
答案 0 :(得分:3)
您可以将其更改为
<property name="maxIdleTime" value="0" /> //0 = never expire