title: c3p0 database pooling Statement close FAILED. java.sql.SQLRecoverableException: Closed Connection
body: <p>I am newbie to Java and c3p0 database pooling. We have build api on mulesoft and deployed to cloudhub (vpc + vpn config), the application connects to database on premise.</p>
  <p>The application logs shows below warning about connection closed every 12 hours (exactly)</p>
  <pre><code>16:59:32.799     07/28/2021     Worker-0     C3P0PooledConnectionPoolManager[identityToken-&gt;|41d2c93]-HelperThread-#2     WARN
  Statement close FAILED.
  java.sql.SQLRecoverableException: Closed Connection
      at oracle.jdbc.driver.PhysicalConnection.needLine(PhysicalConnection.java:3525)
      at oracle.jdbc.driver.OracleStatement.closeOrCache(OracleStatement.java:1478)
      at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:1461)
      at oracle.jdbc.driver.OracleStatementWrapper.close(OracleStatementWrapper.java:122)
      at com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:53)
      at com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:325)
      at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.testPooledConnection(C3P0PooledConnectionPool.java:510)
      at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.testPooledConnection(C3P0PooledConnectionPool.java:464)
      at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishIdleResource(C3P0PooledConnectionPool.java:436)
      at com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask.run(BasicResourcePool.java:2211)
      at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
  </code></pre>
  <p>If a request is received within last few minutes reaching 12 hr time then it fails with 500 error  <code>connection.ConnectionException: An attempt by a client to checkout a Connection has timed out</code></p>
  <p>I have configured spring based datasource and here is my configuration</p>
  <pre><code>&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
  xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  
  
  xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
  http://www.springframework.org/schema/jdbc
  http://www.springframework.org/schema/jdbc/spring-jdbc-4.2.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-4.2.xsd
  http://www.springframework.org/schema/security
  http://www.springframework.org/schema/security/spring-security-4.2.xsd&quot;&gt;
  
  
  
  &lt;bean id=&quot;oracle-jdbcdatasource&quot; class=&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot; destroy-method=&quot;close&quot;&gt;
  &lt;property name=&quot;driverClass&quot; value=&quot;oracle.jdbc.driver.OracleDriver&quot;/&gt;
  &lt;property name=&quot;jdbcUrl&quot; value=&quot;jdbc:oracle:thin:@${oracle.host}:${oracle.port}/${oracle.database}&quot;/&gt;
  &lt;property name=&quot;user&quot; value=&quot;${oracle.username}&quot;/&gt;
  &lt;property name=&quot;password&quot; value=&quot;${oracle.password}&quot;/&gt;
  &lt;property name=&quot;minPoolSize&quot; value=&quot;1&quot;/&gt;
  &lt;property name=&quot;maxPoolSize&quot; value=&quot;5&quot;/&gt;
  &lt;property name=&quot;initialPoolSize&quot; value=&quot;1&quot;/&gt;
  &lt;property name=&quot;acquireIncrement&quot; value=&quot;1&quot;/&gt;
  &lt;property name=&quot;idleConnectionTestPeriod&quot; value=&quot;300&quot;/&gt;
  &lt;property name=&quot;maxStatements&quot; value=&quot;0&quot;/&gt;
  &lt;property name=&quot;checkoutTimeout&quot; value=&quot;60000&quot;/&gt;
  &lt;property name=&quot;testConnectionOnCheckout&quot; value=&quot;true&quot; /&gt;
  &lt;property name=&quot;testConnectionOnCheckin&quot; value=&quot;true&quot; /&gt;
  &lt;property name=&quot;preferredTestQuery&quot; value=&quot;select 1 from dual&quot; /&gt;
  &lt;property name=&quot;maxConnectionAge&quot; value=&quot;14400&quot; /&gt;
  &lt;property name=&quot;maxIdleTime&quot; value=&quot;7200&quot; /&gt;
  &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  <p>I have set <code>maxConnectionAge</code> to 14400 (4hrs) and <code>maxIdleTime</code> to 7200 (2hr) so I was not expecting to see connection closed error as it should have destroyed the connection before 12 hours and new connection should be in-place.</p>
  <p>Version details</p>
  <ul>
  <li>Mule Runtime - 4.3.0</li>
  <li>Oracle jdbc8 - 19.3.0.0</li>
  <li>c3p0 - 0.9.5.2</li>
  </ul>
  <p>Can someone please advise if I am missing any configuration for c3p0 pooling ?</p>
  <p>Thanks</p>