|Oracle® Database JDBC Developer's Guide
12c Release 1 (12.1)
|PDF · Mobi · ePub|
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:
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.
This section describes how to enable DRCP in the server side and the client 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.
sqlplus /nolog connect / as sysdba execute dbms_connection_pool.start_pool();
sqlplus /nolog connect / as sysdba execute dbms_connection_pool.stop_pool();
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);
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.OracleConnectionPoolDataSourceas the connection factory.
Pass a non-null and non-empty String value to the connection property
SERVER=POOLED) to the
CONNECT_DATA in the long connection string
You can also specify
(SERVER=POOLED) in short URL from as follows:
Example 23-1 shows how to enable DRCP on client side:
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.
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 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
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
See Also:Oracle Database JDBC Java API Reference