title: Need of DataSource for oracle JDBC driver with enable/disable CacheConnection
body: <p>There are Oracle 11g2 and application Java based of spring<br><br>
  Need of DataSource for oracle JDBC driver with enable/disable CacheConnection functional in runtime - i.e. if CacheConnection is enable new connection not established if there are free connection in DataSource, if CacheConnection is disable always new connection established and existence is closing after put in idle
  <br>
  <br>
  Early we used apache DataSource:</p>
  
  <pre><code>&lt;bean id="datasourceClassic" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
                  &lt;property name="driverClassName" value="oracle.jdbc.OracleDriver" /&gt; 
                  &lt;property name="url" value="jdbc:oracle:oci:@TEST" /&gt;
                  &lt;property name="username" value="TEST" /&gt;
                  &lt;property name="password" value="TEST" /&gt;
                  &lt;property name="maxActive" value="10" /&gt;
                  &lt;property name="defaultAutoCommit" value="false" /&gt; 
  &lt;/bean&gt;
  </code></pre>
  
  <p>-- but this data source don't have functional for enable/disable CacheConnection<br>
  <br>
  We tested <code>OracleDataSource</code>:<br>
      </p>
  
  <pre><code>        &lt;property name="URL" value="jdbc:oracle:oci:@TEST" /&gt;
          &lt;property name="user" value="TEST" /&gt;
          &lt;property name="password" value="TEST" /&gt;
          &lt;property name="connectionCachingEnabled" value="true" /&gt;
          &lt;property name="connectionCacheProperties"&gt;
              &lt;props&gt; 
                  &lt;prop key="MinLimit"&gt;0&lt;/prop&gt; 
                  &lt;prop key="MaxLimit"&gt;1&lt;/prop&gt; 
                  &lt;prop key="InitialLimit"&gt;0&lt;/prop&gt; 
                  &lt;prop key="InactivityTimeout"&gt;10&lt;/prop&gt; 
                  &lt;prop key="ConnectionWaitTimeout"&gt;10&lt;/prop&gt;
                  &lt;prop key="ValidateConnection"&gt;true&lt;/prop&gt;
              &lt;/props&gt; 
          &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>-- have this functional but it work only if explicity set up this options in context.xml, and method <code>setConnectionCachingEnabled</code> depreceted from runtime<br>
  <br>
  Oracle since 11g2 recomended use <strong>Universal Connection Pool (UCP)</strong>:<br></p>
  
  <pre><code>&lt;bean id="datasource2" class="oracle.ucp.jdbc.PoolDataSourceFactory" factory-method="getPoolDataSource"&gt;
          &lt;property name="connectionFactoryClassName" value="oracle.jdbc.pool.OracleDataSource"/&gt;
          &lt;property name="connectionPoolName" value="TEST"/&gt;
  
          &lt;property name="URL" value="jdbc:oracle:oci:@TEST" /&gt;
          &lt;property name="user" value="TEST" /&gt;
          &lt;property name="password" value="TEST" /&gt;
          &lt;property name="initialPoolSize" value="0" /&gt;
          &lt;property name="minPoolSize" value="0" /&gt;
          &lt;property name="maxPoolSize" value="1" /&gt;
          &lt;property name="validateConnectionOnBorrow" value="true" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>-- but this pool also didn't have functional to enable/disable CacheConnection...
  <br>
  <br>
  <br>
  Any idea of what DataSource can satisfy my requirements?
  <br>
  <br>
  <br>
  <strong>UPDATE:</strong><br>
  I test next trik with <code>org.apache.commons.dbcp.BasicDataSource</code>:<br></p>
  
  <pre><code>/* "Disable" CacheConnection  */
  BasicDataSource bds = ... //get DataSource
  bds.setMaxIdle(0);
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>/* "Enable" CacheConnection */
  BasicDataSource bds = ... //get DataSource
  bds.setMaxIdle(bds.getMaxActive());
  </code></pre>
  
  <p>Works like <code>&lt;property name="connectionCachingEnabled" value="true" /&gt;</code> - what do you think about this?</p>