IBM Support

The Oracle database does not cache all of the connections

Troubleshooting


Problem

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

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"DB Connections\/Connection Pooling","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0","Edition":"Base;Express;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SS7K4U","label":"WebSphere Application Server for z\/OS"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"DB Connections\/Connection Pooling","Platform":[{"code":"","label":""}],"Version":"7.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
06 June 2019

UID

swg21318192