javamysqljdbcconnection-poolingc3p0

No operations allowed after connection closed.Connection was implicitly closed by the driver. C3P0


I am trying to upload images(one by one) using c3p0 connection pooling but my jdbc type 4 driver(connecting to mysql) keeps on closing the connection. I have seen that the maximum timeout in the configuration of mysql is set to 300 seconds. Here is how my persistence xml uses 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>

Can someone explain what exactly is causing the driver to implicitly close the connection. Also, how can i reolve this issue?

Here is the error message I get:

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.

Solution

  • Can you change this to

    <property name="maxIdleTime" value="0" />  //0 = never expire