Skip Headers
Oracle® Database JDBC Developer's Guide
12c Release 1 (12.1)

E17657-14
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

23 Database Resident Connection Pooling

Database Resident Connection Pool (DRCP) is a connection pool in the server that is shared across many clients. You should use DRCP in connection pools where the number of active connections is fairly less than the number of open connections. As the number of instances of connection pools that can share the connections from DRCP pool increases, the benefits derived from using DRCP increases. DRCP increases Database server scalability and resolves the resource wastage issue that is associated with middle-tier connection pooling.

This chapter contains the following sections:

Overview of Database Resident Connection Pooling

In middle-tier connection pools, every connection cache maintains a minimum number of connections to the server. Each connection represents used up resources at the server. All these open connections are not utilized at any given time, which means that there are unused resources that unnecessarily take up server resources. In a multiple middle-tier scenario, these connections are not shared with any other middle tier and are retained in the cache even if some of these are idle. However, a large number of such middle-tier connection pools increase the number of inactive connections to the Database server significantly and waste a lot of Database resources because all the connections do not remain active simultaneously.

For example, in a middle-tier connection pool, if the minimum pool size is 200, then the connection pool has 200 connections to the server, and the Database server has 200 server processes associated with these connections. If there are 30 middle tiers with a connection pool of minimum size 200, then the server has 6000 (200 * 30) corresponding server processes running. Typically, on an average only 5% of the connections, and in turn, server processes are in use at any given time. So, out of the 6,000 server processes, only 300 server processes are active at any given time. This leads to over 5,700 unused server processes on the server. These unused processes are the wasted resources on the server.

The Database Resident Connection Pool implementation creates a pool on the server side, which is shared across multiple client pools. This significantly lowers memory consumption on the server because of reduced number of server processes on the server and increases the scalability of the Database server.

Enabling Database Resident Connection Pooling

This section describes how to enable DRCP in the server side and the client side:

Enabling DRCP on the Server Side

You must be a database administrator (DBA) and must log on as SYSDBA to start and end a pool. This section contains the following subsections:

Note:

The features of DRCP can be leveraged only with a connection pool on the client because JDBC does not have a default pool on its own.

Starting a Pool

Run the dbms_connection_pool.start_pool method with the default settings to start the default pool, SYS_DEFAULT_CONNECTION_POOL. For example:

sqlplus /nolog
connect / as sysdba
execute dbms_connection_pool.start_pool();

Ending a Pool

Run the dbms_connection_pool.stop_pool method with the default settings to end the pool. For example:

sqlplus /nolog
connect / as sysdba
execute dbms_connection_pool.stop_pool();

Setting the Statement Cache Size

If you use DRCP, caching is also done at the server side. So, you must specify the statement cache size on the server side in the following way, where 50 is the preferred size:

execute DBMS_CONNECTION_POOL.CONFIGURE_POOL (session_cached_cursors=>50);

Enabling DRCP on the Client Side

Perform the following steps to enable DRCP on the client side:

Note:

In Example 23-1, we are using Universal Connection Pool as the client-side connection pool. For any other connection pools, you can enable DRCP by performing the following two steps and using oracle.jdbc.pool.OracleConnectionPoolDataSource as the connection factory.
  • Pass a non-null and non-empty String value to the connection property oracle.jdbc.DRCPConnectionClass

  • Append (SERVER=POOLED) to the CONNECT_DATA in the long connection string

You can also specify (SERVER=POOLED) in short URL from as follows:

jdbc:oracle:thin:@//<host>:<port>/<service_name>[:POOLED]

For example:

jdbc:oracle:thin:@//localhost:5221/orcl:POOLED

Example 23-1 shows how to enable DRCP on client side:

Example 23-1 Enabling DRCP on Client Side Using Universal Connection Pool

String url = "jdbc:oracle:thin:@//localhost:5521/orcl:POOLED";
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
// Set DataSource Property
pds.setUser("HR");
pds.setPassword("hr");
System.out.println ("Connecting to " + url);
pds.setURL(url);
pds.setConnectionPoolName("HR-Pool1");
pds.setMinPoolSize(2);
pds.setMaxPoolSize(3);
pds.setInitialPoolSize(2);
Properties prop = new Properties();
prop.put("oracle.jdbc.DRCPConnectionClass", "HR-Pool1");
pds.setConnectionProperties(prop);

See Also:

Oracle Universal Connection Pool for JDBC Developer's Guide for more information about Universal Connection Pool

Note:

In UCP, if you do not provide a connection class, then the connection pool name is used as the connection class name by default.

Sharing Pooled Servers Across Multiple Connection Pools

To share pooled server processes on the server across multiple Connection pools, set the same DRCP Connection class name for all the pooled server processes on the server. You can set the DRCP Connection class name using the connection property oracle.jdbc.DRCPConnectionClass as discussed in "Enabling DRCP on the Client Side".

DRCP Tagging

DRCP enables you to request the Server connection pool to associate a Server process with a particular tag name.

See Also:

Oracle Call Interface Programmer's Guide for more information about session pooling and connection tagging

APIs for Using DRCP

In DRCP, you can apply a tag to a given connection and retrieve that tagged connection later. Connection tagging enhances session pooling because you can retrieve specific sessions easily.

If you want to take advantage of DRCP with higher granular control for your Custom connection pool implementations, then you must use the following APIs declared in the oracle.jdbc.OracleConnection interfaces:

  • attachServerConnection

  • detachServerConnection

  • isDRCPEnabled

  • needToPurgeStatementCache