Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Administration Guide

- Previous: Chapter 2 Deploying Applications
- Next: Setting Up Database Access

# About JDBC Resources and Connection Pools

- JDBC Resources

- JDBC Connection Pools

- How JDBC Resources and Connection Pools Work Together

## JDBC Resources

To store, organize, and retrieve data, most applications use relational databases. J2EE applications access relational databases through the JDBC API.

A JDBC resource (data source) provides applications with a means of connecting to a database. Typically, the administrator creates a JDBC resource for each database accessed by the applications deployed in a domain. (However, more than one JDBC resource can be created for a database.)

To create a JDBC resource, specify a unique JNDI name that identifies the resource. (See the section JNDI Names and Resources.) Expect to find the JNDI name of a JDBC resource in `java:comp/env/jdbc` subcontext. For example, the JNDI name for the resource of a payroll database could be `java:comp/env/jdbc/payrolldb`. Because all resource JNDI names are in the `java:comp/env` subcontext, when specifying the JNDI name of a JDBC resource in the Admin Console, enter only `jdbc/`name. For example, for a payroll database specify `jdbc/payrolldb`.

See Also:

- JNDI Names and Resources

- JDBC Connection Pools

- How JDBC Resources and Connection Pools Work Together

- To create a JDBC resource

- To edit a JDBC resource

- To delete a JDBC resource

- To enable or disable a JDBC resource

## 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 different database vendors. Some common properties are the database’s name (URL), user name, and password.

See Also:

- JDBC Resources

- How JDBC Resources and Connection Pools Work Together

- To create a JDBC connection pool

- To edit a JDBC connection pool

- To verify connection pool settings

- To delete a JDBC connection pool

## How JDBC Resources and Connection Pools Work Together

To store, organize, and retrieve data, most applications use relational databases. J2EE 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 specifies a connection pool.

2. Via the JDBC resource, the application gets a database connection.

   Behind the scenes, the application server retrieves a physical connection from the connection pool that corresponds to the database. The pool defines connection attributes such as the database name (URL), user name, and password.

3. Now that it’s connected to the database, the application can read, modify, and add data to the database.

   The applications access the database by making calls to the JDBC API. The JDBC driver translates the application’s JDBC calls into the protocol of the database server.

4. When it’s finished accessing the database, the application closes the connection.

   The application server returns the connection to the connection pool. Once it’s back in the pool, the connection is available for the next application.

See Also:

- JNDI Names and Resources

- JDBC Resources

- JDBC Connection Pools

- To Set Up Database Access

- Previous: Chapter 2 Deploying Applications
- Next: Setting Up Database Access

- © 2010, Oracle Corporation and/or its affiliates