When creating a JDBC resource, you must identify:
1. The JNDI Name. By convention, the name begins with the jdbc/ string. For example:
jdbc/payrolldb. Don’t forget the forward slash.
2. Select a connection pool to be associated with the new JDBC resource.
3. Specify the settings for the resource.
4. Identify the targets (clusters and standalone server instance) on which the resource is
available.
JDBC Connection Pools
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.
The properties of connection pools can vary with dierent database vendors. Some common
properties are the database’s name (URL), user name, and password.
See Also:
■
“JDBC Resources” on page 43
■
“How JDBC Resources and Connection Pools Work Together” on page 44
■
“Editing a JDBC Connection Pool” on page 48
How JDBC Resources and Connection Pools Work Together
To store, organize, and retrieve data, most applications use relational databases. Java EE
applications access relational databases through the JDBC API. Before an application can access
a database, it must get a connection.
At runtime, here’s what happens when an application connects to a database:
1. The application gets the JDBC resource (data source) associated with the database by
making a call through the JNDI API.
Given the resource’s JNDI name, the naming and directory service locates the JDBC
resource. Each JDBC resource species a connection pool.
2. Via the JDBC resource, the application gets a database connection.
JDBCConnection Pools
SunGlassFishEnterpriseServer2.1AdministrationGuide • December200844