Whencreating a JDBC resource, you must identify:
1. TheJNDI Name. By convention, the name begins with the jdbc/ string. For example:
jdbc/payrolldb.Don’t forget the forward slash.
2. Selecta connection pool to be associated with the new JDBC resource.
3. Specifythe settings for the resource.
4. Identifythe targets (clusters and standalone server instance) on which the resource is
available.
JDBC Connection Pools
Tocreate a JDBC resource, specify the connection pool with which it is associated. Multiple
JDBCresources can specify a single connection pool.
AJDBC connection pool is a group of reusable connections for a particular database. Because
creatingeach new physical connection is time consuming, the server maintains a pool of
availableconnections to increase performance. When an application requests a connection, it
obtainsone from the pool. When an application closes a connection, the connection is returned
tothe pool.
Theproperties of connection pools can vary with dierent database vendors. Some common
propertiesare the database’s name (URL), user name, and password.
SeeAlso:
“JDBCResources” on page 43
“HowJDBC Resources and Connection Pools Work Together” on page 44
“Editinga JDBC Connection Pool” on page 48
How JDBC Resourcesand Connection Pools Work Together
Tostore, organize, and retrieve data, most applications use relational databases. Java EE
applicationsaccess relational databases through the JDBC API. Before an application can access
adatabase, it must get a connection.
Atruntime, here’swhat happens when an application connects to a database:
1. Theapplication gets the JDBC resource (data source) associated with the database by
makinga call through the JNDI API.
Giventhe resource’s JNDI name, the naming and directory service locates the JDBC
resource.Each JDBC resource species a connection pool.
2. Viathe JDBC resource, the application gets a database connection.
JDBCConnection Pools
SunGlassFishEnterprise Ser ver2.1 Administration Guide • December 200844