title: c3p0 Connection pool memory leak redeploy tomcat
body: <p>I have these codes for closing c3p0 connection manager but it seems that there is still one more thread that was not closed . Am i missing something ?</p>
  
  <pre><code>Oct 11, 2016 5:12:09 PM org.springframework.context.support.AbstractApplicationContext doClose
  INFO: Closing WebApplicationContext for namespace 'dispatcherServlet-servlet': startup date [Tue Oct 11 17:11:58 PHT 2016]; parent: Root WebApplicationContext
  2016-10-11 17:12:09 - [INFO ] CRMContextListener - Trying to Close
  2016-10-11 17:12:09 - [INFO ] CRMContextListener - Close Success
  Oct 11, 2016 5:12:09 PM      org.springframework.context.support.AbstractApplicationContext doClose
  INFO: Closing Root WebApplicationContext: startup date [Tue Oct 11 17:11:44 PHT 2016]; root of context hierarchy
  Oct 11, 2016 5:12:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
  SEVERE: A web application registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. Oct 11, 2016 5:12:09 PM     org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  SEVERE: A web application appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken-&gt;2xjsis9j1do3mrp1m3tqb8|fb6fd9c]-DeferredStatementDestroyerThread-#0] but has failed to stop it. This is very likely to create a memory leak.
  </code></pre>
  
  <p>This is the code for my servlet listener</p>
  
  <pre><code>public void contextDestroyed(ServletContextEvent sce) {
      logger.info("Trying to Close");
  
      for (Object o : C3P0Registry.getPooledDataSources()) {
          try {
              ((PooledDataSource) o).close();
          } catch (Exception e) {
              logger.info("No thread was open...");
          }
      }
  
      logger.info("Close Success");
  }
  </code></pre>
  
  <p>And here is my configuration for c3p0 xml</p>
  
  <pre><code>&lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt;
      &lt;property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /&gt;
      &lt;property name="jdbcUrl" value="jdbc:oracle:thin:@sph-pdc-vm  1042:1521:DEV" /&gt;
      &lt;property name="user" value="TSW" /&gt;
      &lt;property name="password" value="TSW2015#" /&gt;
      &lt;property name="minPoolSize" value="2" /&gt;
      &lt;property name="maxPoolSize" value="20" /&gt;
      &lt;property name="initialPoolSize" value="5" /&gt;
      &lt;property name="testConnectionOnCheckin" value="true" /&gt;
      &lt;property name="idleConnectionTestPeriod" value="100" /&gt;
      &lt;property name="maxIdleTimeExcessConnections" value="5" /&gt;
      &lt;property name="maxStatementsPerConnection" value="10" /&gt;
      &lt;property name="acquireIncrement" value="1" /&gt;
      &lt;property name="statementCacheNumDeferredCloseThreads" value="1" /&gt;
      &lt;property name="acquireRetryAttempts" value="2" /&gt;
      &lt;property name="acquireRetryDelay" value="2000" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Thanks in advance....</p>