Setting up a Connection Pool on the GlassFish Application Server

See Also

A JDBC connection pool is a group of reusable connections that the application server maintains for a particular database. Applications requesting a connection to a database obtain that connection from the pool. When an application closes a connection, the connection is returned to the pool.

Connection pooling reduces the transaction time of connecting to a database because connection objects providing access to a database source are shared, thus avoiding the creation of a new physical connection every time a connection is requested.

A connection pool is required if you want to create a JDBC resource. You can create connection pools for a project using the New File wizard.

To create a connection pool for your project:

  1. Choose File > New (Ctrl-N).
  2. Choose a project from the combo box.
  3. Select GlassFish in the Categories pane, JDBC Connection Pool in the File Types pane, and click Next.
  4. (required) Give the connection pool a name.
  5. Select to either use an existing database connection or create a new connection by choosing a configuration from the list.
  6. Select the XA checkbox if the connection is an XA transaction.
  7. Click Next.
  8. The Datasource classname is determined by the connection you selected.
  9. Enter a description for the pool.
  10. Enter any properties for the connection. You may need to enter the URL for the database and user name and password to connect.
  11. Click Next if you want to modify the default properties for the connection. You can change these properties later by editing the sun-resources.xml file.
  12. Click Finish.

Once you have created a connection pool in your project, the resource needs to be registered with the server to make it available to all applications and resources. The resource is automatically registered when the project is deployed.

See Also
About Connection Pools
Connecting to a Database
Registering a Resource with the GlassFish Application Server

Legal Notices