title: Many threads created using C3P0 with Hibernate/Spring
body: <p>I do a project merging Hibernate and Spring in a Java web application, using Tomcat under Linux environment. Due to the Mysql 8 hours timeout problem, we want to use C3P0 to manage a connection pool with our Mysql database.
  But when we use it, we have numerous threads that are created. I figured it out beacause I did on each request a print of all of them with a memory status that show me the increasing memory  and that kind of threads:</p>
  
  <blockquote>
    <ul>
    <li>name: C3P0PooledConnectionPoolManager[identityToken->1hged7o8r13kpj7n1h3ycia|39c446]-HelperThread-#0   daemon: true   group! main   groupParent: system   alive: true   interrupted: false</li>
    <li>name: C3P0PooledConnectionPoolManager[identityToken->1hged7o8r13kpj7n1h3ycia|17ec0e8]-AdminTaskTimer   daemon: true   group! main   groupParent: system   alive: true   interrupted: false</li>
    </ul>
  </blockquote>
  
  <p>It can produce more than 500 threads like these ones, after enough time.</p>
  
  <p>Here is my Hibernate.cfg.xml:</p>
  
  <pre><code>    &lt;property name="connection.provider_class"&gt;
              org.hibernate.connection.C3P0ConnectionProvider&lt;/property&gt;
      &lt;property name="hibernate.c3p0.acquire_increment"&gt;1&lt;/property&gt; 
      &lt;property name="hibernate.c3p0.idle_test_period"&gt;5&lt;/property&gt;
      &lt;property name="hibernate.c3p0.max_size"&gt;100&lt;/property&gt; 
      &lt;property name="hibernate.c3p0.max_statements"&gt;100&lt;/property&gt; 
      &lt;property name="hibernate.c3p0.min_size"&gt;10&lt;/property&gt; 
      &lt;property name="hibernate.c3p0.timeout"&gt;5&lt;/property&gt;
  
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
      &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/myBase&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;
      &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
      &lt;property name="hibernate.default_schema"&gt;myProject&lt;/property&gt;
      &lt;property name="hibernate.query.factory_class"&gt;org.hibernate.hql.classic.ClassicQueryTranslatorFactory&lt;/property&gt;
      &lt;property name="show_sql"&gt;false&lt;/property&gt;
  
      &lt;property name="cache.provider_class"&gt;
        org.hibernate.cache.NoCacheProvider
      &lt;/property&gt;         
  </code></pre>
  
  <p>I also tried to add a C3P0 propeties file, but except reducing the helper thread number, it don't delete the unsused thread:</p>
  
  <pre><code>    c3p0.maxStatements=5    
  
  c3p0.maxIdleTime=10
  
  c3p0.numHelperThreads=1
  
  c3p0.testConnectionOnCheckout=true
  c3p0.preferredTestQuery=SELECT 1
  
  c3p0.initialPoolSize=1
  c3p0.minPoolSize=1
  c3p0.maxPoolSize=10
  
  c3p0.acquireIncrement=1
  c3p0.idleConnectionTestPeriod=1
  </code></pre>
  
  <p>Does anyone have an idea of why this happen and how to solve this problem? </p>
  
  <p>Thanks a lot.</p>