IBM Support

The Oracle database does not cache all of the connections

Technote (troubleshooting)


Problem(Abstract)

When you use the oracle.jdbc.pool.OracleConnectionCacheManager custom property with the Oracle.jdbc.pool.OracleDataSource data source, connections to an Oracle database might not be cached.

Cause

Custom properties on an Oracle data source are represented as a collection, which has no particular order. Therefore, it is not possible to configure data source properties in any order that guarantees that all of the connections are cached by the Oracle database.

Diagnosing the problem

The following samples demonstrate instances in which caching does and does not occur.

In the following example, caching occurs:

import java.sql.Connection;
import java.sql.SQLException;

import oracle.jdbc.pool.OracleConnectionCacheManager;
import oracle.jdbc.pool.OracleDataSource;

public class OraceCachingBug {

  static String                       url  = null;
  static OracleConnectionCacheManager occm = null;

  public static void cacheCreatedSuccessfully()
  throws Throwable
{

    OracleDataSource ods = new OracleDataSource();

    // The following property ordering results in
       a cache being created.
    ods.setConnectionCachingEnabled(true);
    ods.setURL("jdbc:oracle:thin:@localhost:1521:IBM");
    ods.setConnectionCacheName("ICC");

    ods.setUser("scott");
    ods.setPassword("manager1");

    Connection conn = ods.getConnection("scott", "manager1");

    System.out.println("before: " + occm.getNumberOfAvailableConnections("ICC") + "
connections are available in cache ICC");
    conn.close();
    System.out.println("after: " + occm.getNumberOfAvailableConnections("ICC") + "
connections are available in cache ICC");

    System.out.println("success");

  }

In the following example, caching does not occur:

public static void noCacheCreatedDueToOraBug()
throws Throwable
{

    OracleDataSource ods = new OracleDataSource();

    // The following property ordering causes no exception,
       but no cache is created.
    ods.setConnectionCacheName("ICC");
    ods.setURL("jdbc:oracle:thin:@localhost:1521:IBM");
    ods.setConnectionCachingEnabled(true);
    ods.setUser("scott");
    ods.setPassword("manager1");

    Connection conn = ods.getConnection("scott", "manager1");

    System.out.println("before: " + occm.getNumberOfAvailableConnections("ICC") + "
connections are available in cache ICC");
    conn.close();
    System.out.println("after: " + occm.getNumberOfAvailableConnections("ICC") + "
connections are available in cache ICC");

    System.out.println("success");
  }

  public static void main(String[] args) throws Throwable {

    occm = OracleConnectionCacheManager.getConnectionCacheManagerInstance();

    System.out.println("test combination that causes cache
    to NOT get created");
    try {
      noCacheCreatedDueToOraBug();
    }
    catch (SQLException x) {
      System.out.println("test failed, exception is: " + x);
    }

    System.out.println("test combination that causes cache
    to be created");
    cacheCreatedSuccessfully();

    System.out.println("all done..");
  }
 
}


Resolving the problem

Contact Oracle support and reference the 6638862 fix.

Related information

V7 Release Notes

Cross reference information
Segment Product Component Platform Version Edition
Application Servers WebSphere Application Server for z/OS DB Connections/Connection Pooling 7.0

Document information

More support for: WebSphere Application Server
DB Connections/Connection Pooling

Software version: 7.0

Operating system(s): AIX, HP-UX, IBM i, Linux, Solaris, Windows

Software edition: Base, Express, Network Deployment

Reference #: 1318192

Modified date: 25 September 2008


Translate this page: