Sun Java System Application Server Enterprise Edition 8.2 Administration Guide

Creating a JDBC Connection Pool

To create a JDBC resource, specify the connection pool with which it is associated. Multiple JDBC resources can specify a single connection pool.

A JDBC connection pool is a group of reusable connections for a particular database. Because creating each new physical connection is time consuming, the server maintains a pool of available connections to increase performance. When an application requests a connection, it obtains one from the pool. When an application closes a connection, the connection is returned to the pool.

When creating a connection pool , you are actually defining the aspects of a connection to a specific database. Before creating the pool, you must first install and integrate the JDBC driver. The properties of connection pools can vary with different database vendors. Some common properties are the database’s name (URL), user name, and password.

Certain data specific to the JDBC driver and the database vendor must be entered. Before proceeding, gather the following information:

A JDBC connection pool is a group of reusable connections for a particular database. When creating the pool with the Administration Console, the Administrator is actually defining the aspects of a connection to a specific database.

Before creating the pool, you must first install and integrate the JDBC driver. When building the Create Connection Pool pages, certain data specific to the JDBC driver and the database vendor must be entered. Before proceeding, gather the following information:

Define the general settings values as specified by the JDBC driver you installed. These settings are the names of classes or interfaces in the Java programming language.

Parameter

Description

DataSource Class Name

The vendor-specific class name that implements the DataSource and / or XADataSource APIs. This class is in the JDBC driver.

Resource Type

Choices include javax.sql.DataSource (local transactions only), javax.sql.XADataSource (global transactions), and java.sql.ConnectionPoolDataSource (local transactions, possible performance improvements).

Additionally, you must define a set of physical database connections that reside in the pool. When an application requests a connection, the connection is removed from the pool, and when the application releases the connection, it is returned to the pool.

Parameter

Description

Initial and Minimum Pool Size 

The minimum number of connections in the pool. This value also determines the number of connections placed in the pool when the pool is first created or when application server starts. 

Maximum Pool Size 

The maximum number of connections in the pool. 

Pool Resize Quantity 

When the pool shrinks toward the minimum pool size it is resized in batches. This value determines the number of connections in the batch. Making this value too large delays connection recycling; making it too small will be less efficient. 

Idle Timeout 

The maximum time in seconds that a connection can remain idle in the pool. After this time expires, the connection is removed from the pool. 

Max Wait Time 

The amount of time the application requesting a connection will wait before getting a connection timeout. Because the default wait time is long, the application might appear to hang indefinitely. 

Optionally, the application server can validate connections before they are passed to applications. This validation allows the application server to automatically reestablish database connections if the database becomes unavailable due to network failure or database server crash. Validation of connections incurs additional overhead and slightly reduces performance.

Parameter

Description

Connection Validation 

Select the Required checkbox to enable connection validation. 

Validation Method 

The application server can validate database connections in three ways: auto-commit, metadata, and table. 

auto-commit and metadata - The application server validates a connection by calling the con.getAutoCommit() and con.getMetaData() methods. However, because many JDBC drivers cache the results of these calls, they do not always provide reliable validations. Check with the driver vendor to determine whether these calls are cached or not.

auto-commit validation makes use of two methods for validating the connection. getAutoCommit() is used to retrieve the current state of auto-commit and setAutoCommit() to change the state of auto-commit. This allows actual contact with the database to take place. getAutomCommit() might or might not contact the database, depending on the implementation. Actual physical connection will be wrapped for different purposes, such as a connection pool.


Note –

Databases such as Oracle do some caching for setAutoCommit(). For such databases, actual connection validation might not happen, so table-based validation is recommended.


table - The application queries a database table that are specified. The table must exist and be accessible, but it doesn't require any rows. Do not use an existing table that has a large number of rows or a table that is already frequently accessed. 

Table Name 

If you selected table from the Validation Method combo box, then specify the name of the database table here. 

On Any Failure 

If you select the checkbox labelled Close All Connections, if a single connection fails, then the application server closes all connections in the pool and then reestablish them. If you do not select the checkbox, then individual connections are reestablished only when they are used. 

Because a database is usually accessed by many users concurrently, one transaction might update data while another attempts to read the same data. The isolation level of a transaction defines the degree to which the data being updated is visible to other transactions. For details on isolation levels, refer to the documentation of the database vendor.

Parameter

Description

Transaction Isolation 

Makes it possible to select the transaction isolation level for the connections of this pool. If left unspecified, the connections operate with default isolation levels provided by the JDBC driver. 

Guaranteed Isolation Level 

Only applicable if the isolation level has been specified. If you select the Guaranteed checkbox, then all connections taken from the pool have the same isolation level. For example, if the isolation level for the connection is changed programmatically (with con.setTransactionIsolation) when last used, this mechanism changes the status back to the specified isolation level.