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:
- Choose File > New (Ctrl-N).
- Choose a project from the combo box.
- Though the resource can be saved in either the EJB module or the Web module,
Java EE patterns recommend saving the resource in the EJB module to allow greater flexibility and reusability.
- Select GlassFish in the Categories pane, JDBC Connection Pool in the File Types pane, and click Next.
- (required) Give the connection pool a name.
- Select to either use an existing database connection or create a new connection by choosing
a configuration from the list.
- Select the XA checkbox if the connection is an XA transaction.
- Click Next.
- The Datasource classname is determined by the connection you selected.
- Enter a description for the pool.
- Enter any properties for the connection. You may need to enter the URL for the database and user name and
password to connect.
- 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.
- 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