title: c3p0 connection pooling library with Hibernate 3.2.6/JPA - Cannot open connection
body: <p>My application have two quartz jobs readning two different tables from Oracle DB in the same time.
  I am trying to get a connection from pool using c3p0 with Hibernate and Oracle. When Tomcat 7 starts it seems like C3P0 is initialized:</p>
  <blockquote>
  <p>2021-02-15 18:47:26,271 [INFO] Hibernate EntityManager 3.2.1.GA <br>
  2021-02-15 18:47:26,290 [INFO] Hibernate Annotations 3.2.1.GA <br>
  2021-02-15 18:47:26,299 [INFO] Hibernate 3.2.6<br> ... <br> 2021-02-15
  18:47:27,473 [INFO] Initializing c3p0-0.9.1 [built 16-January-2007
  14:46:42; debug? true; trace: 10] <br> 2021-02-15 18:47:27,621 [INFO]
  Initializing c3p0 pool...
  com.mchange.v2.c3p0.PoolBackedDataSource@add8f7b3 [
  connectionPoolDataSource -&gt;
  com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@e6d03554 [
  acquireIncrement -&gt; 1, acquireRetryAttempts -&gt; 30, acquireRetryDelay
  -&gt; 1000, autoCommitOnClose -&gt; false, automaticTestTable -&gt; null, ... ]<br></p>
  <p>2021-02-15 18:47:28,240 [INFO] RDBMS: Oracle, version: Oracle Database
  11g Release 11.1.0.0.0 - Production <br> 2021-02-15 18:47:28,241
  [INFO] JDBC driver: Oracle JDBC driver, version: 10.2.0.4.0 <br>
  2021-02-15 18:47:28,280 [INFO] Using dialect:
  org.hibernate.dialect.Oracle10gDialect <br> <br/></p>
  </blockquote>
  <p>But after a few lines, it is still showing Hibernate built-in connection pool, I don't know if that's the way it should be? : <br/></p>
  <blockquote>
  <p>2021-02-15 18:47:37,726 [INFO] Using Hibernate built-in connection
  pool (not for production use!)<br/> 2021-02-15 18:47:37,726 [INFO]
  Hibernate connection pool size: 20 <br/></p>
  </blockquote>
  <p>Anyway, after first job successful got data from Oracle DB, second job could not obtain a connection from pool because it is closed:<br></p>
  <blockquote>
  <p>2021-02-15 18:48:38,923 [WARN] SQL Error: 0, SQLState: null <br/>
  2021-02-15 18:48:38,923 [ERROR] com.mchange.v2.c3p0.PoolBackedDataSource@add8f7b3
  [ connectionPoolDataSource -&gt;
  com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@e6d03554 [
  acquireIncrement -&gt; 1, acquireRetryAttempts -&gt; 30, acquireRetryDelay
  -&gt; 1000, autoCommitOnClose -&gt; false, automaticTestTable -&gt; null, breakAfterAcquireFailure -&gt; false, checkoutTimeout -&gt; 0,
  connectionCustomizerClassName -&gt; null, connectionTesterClassName -&gt;
  com.mchange.v2.c3p0.impl.DefaultConnectionTester,
  debugUnreturnedConnectionStackTraces -&gt; false, factoryClassLocation -&gt;
  null, forceIgnoreUnresolvedTransactions -&gt; false, identityToken -&gt;
  2zgg5baf1aa5t7d1frz5fs|700f6fc5, idleConnectionTestPeriod -&gt; 3000,
  initialPoolSize -&gt; 10, maxAdministrativeTaskTime -&gt; 0,
  maxConnectionAge -&gt; 0, maxIdleTime -&gt; 300,
  maxIdleTimeExcessConnections -&gt; 0, maxPoolSize -&gt; 20, maxStatements -&gt;
  50, maxStatementsPerConnection -&gt; 0, minPoolSize -&gt; 10,
  nestedDataSource -&gt;
  com.mchange.v2.c3p0.DriverManagerDataSource@2f7ccb64 [ description -&gt;
  null, driverClass -&gt; null, factoryClassLocation -&gt; null, identityToken
  -&gt; 2zgg5baf1aa5t7d1frz5fs|6a16a596, jdbcUrl -&gt; jdbc:oracle:thin:@10.129.12.158:1520:orcl, properties -&gt; {user=<strong><strong><strong>,
  password=</strong></strong></strong>, autocommit=true, release_mode=auto} ],
  preferredTestQuery -&gt; null, propertyCycle -&gt; 0,
  testConnectionOnCheckin -&gt; false, testConnectionOnCheckout -&gt; false,
  unreturnedConnectionTimeout -&gt; 0, usesTraditionalReflectiveProxies -&gt;
  false; userOverrides: {} ], dataSourceName -&gt; null,
  factoryClassLocation -&gt; null, identityToken -&gt;
  2zgg5baf1aa5t7d1frz5fs|63308385, numHelperThreads -&gt; 3 ] <strong>has been
  closed() -- you can no longer use it.</strong> <br/>
  2021-02-15 18:48:38,923 [DEBUG] [docadmin] ccmwsWebQuartz::GenerateDocumentTypeOfRequestJob.generateDocumentTypeOfRequest() - errororg.hibernate.exception.GenericJDBCException: Cannot open connection<br/>
  2021-02-15 18:48:38,923 [DEBUG] ccmwsWebQuartz::GenerateDocumentTypeOfRequestJob.generateRequest(): exception: org.hibernate.exception.GenericJDBCException: Cannot open connection 1613411318923 ms.
  javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection
  at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
  at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
  at com.ct.contentintegration.scheduler.GenerateDocumentTypeOfRequestJob.generateDocumentTypeOfRequest(GenerateDocumentTypeOfRequestJob.java:165)
  at com.ct.contentintegration.scheduler.GenerateDocumentTypeOfRequestJob.generateRequest(GenerateDocumentTypeOfRequestJob.java:89)
  at com.ct.contentintegration.scheduler.GenerateDocumentTypeOfRequestScheduler.execute(GenerateDocumentTypeOfRequestScheduler.java:23)
  at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
  at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)<br/>
  Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection<br/></p>
  </blockquote>
  <p>Configuration file look like this:
  <strong>persistence.xml</strong><br/></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!-- Persistence deployment descriptor for dev profile --&gt;
  &lt;persistence xmlns=&quot;http://java.sun.com/xml/ns/persistence&quot;
      xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd&quot;
      version=&quot;1.0&quot;&gt;
      
      &lt;persistence-unit name=&quot;jpaCcmwsWebJob&quot;&gt;
  
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
  
  &lt;!--                        RAZVOJ                               --&gt;
  
          &lt;properties&gt;
  
              &lt;property name=&quot;hibernate.connection.url&quot; value=&quot;jdbc:oracle:thin:@10.129.12.158:1520:orcl&quot; /&gt;
  
              &lt;property name=&quot;hibernate.dialect&quot; value=&quot;org.hibernate.dialect.Oracle10gDialect&quot; /&gt;
  
              &lt;property name=&quot;hibernate.connection.driver_class&quot; value=&quot;oracle.jdbc.OracleDriver&quot; /&gt;
  
              &lt;property name=&quot;hibernate.connection.password&quot; value=&quot;docadmin2010&quot; /&gt;
  
              &lt;property name=&quot;hibernate.connection.username&quot; value=&quot;docadmin&quot; /&gt;
  
              &lt;property name=&quot;hibernate.show_sql&quot; value=&quot;false&quot; /&gt;
              
  
              
              &lt;property name=&quot;hibernate.c3p0.acquire_increment&quot; value=&quot;1&quot; /&gt;
              &lt;property name=&quot;hibernate.c3p0.min_size&quot; value=&quot;10&quot; /&gt;
            &lt;property name=&quot;hibernate.c3p0.max_size&quot; value=&quot;20&quot; /&gt;
            &lt;property name=&quot;hibernate.c3p0.timeout&quot; value=&quot;300&quot; /&gt;
            &lt;property name=&quot;hibernate.c3p0.max_statements&quot; value=&quot;50&quot; /&gt;
            &lt;property name=&quot;hibernate.connection.provider_class&quot; value=&quot;org.hibernate.connection.C3P0ConnectionProvider&quot; /&gt;
            &lt;property name=&quot;hibernate.c3p0.idle_test_period&quot; value=&quot;3000&quot; /&gt;
  
          &lt;/properties&gt;
  
      &lt;/persistence-unit&gt;
  
  &lt;/persistence&gt;
  </code></pre>
  <p>Oracle connection type is <strong>Basic</strong>. <br/></p>
  <p>Any ideas what I was doing wrong ?</p>