title: Java-Oracle UniversalConnectionPool
body: <p>I am working on a financial application where lots of agents hit the DB (Using UI) very frequently. I am using Oracle UniversalConnectionPool for DB Connection. But soon it creates lots of inactive sessions with DB. I don't have issues with inactive sessions because it puts them in the pool but problem is that after reaching the max limit it give error that</p>
  <blockquote>
  <p>Exception occurred while getting connection:
  oracle.ucp.UniversalConnectionPoolException: All connections in the
  Universal Connection Pool are in use</p>
  </blockquote>
  <p>Here is the code please have a look and help</p>
  <pre><code>private static PoolDataSource  pds = null;
  static UniversalConnectionPoolManager mgr = null;
  try{
      pds = PoolDataSourceFactory.getPoolDataSource();
      pds.setConnectionFactoryClassName(&quot;oracle.jdbc.pool.OracleDataSource&quot;);
          pds.setConnectionPoolName(&quot;JDBC_UCP&quot;);
          
          pds.setInitialPoolSize(2);
          pds.setMinPoolSize(2);
          pds.setMaxPoolSize(10);
          
          pds.setURL(&quot;jdbc:oracle:thin:@192.168.4.5:1521:CDIM&quot;);
          pds.setUser(&quot;baseline&quot;);
          pds.setPassword(&quot;baseline&quot;);
          
          mgr = UniversalConnectionPoolManagerImpl.getUniversalConnectionPoolManager();
          mgr.createConnectionPool((UniversalConnectionPoolAdapter)pds);
          mgr.startConnectionPool(&quot;JDBC_UCP&quot;);
      }catch(Exception e){
          LogManager.error(DBConnection.class, &quot;getConnection : &quot; + e.getMessage());
      }
  </code></pre>
  <p>get Connection like this</p>
  <pre><code>pds.getConnection();
  </code></pre>
  <p>Close Connection like this</p>
  <pre><code>con.close();
  con = null;
  </code></pre>