To prepare a JDBC resource for use in Java EE applications deployed to the GlassFish Server, perform the following tasks:
For information about how to configure some specific JDBC drivers, see Configuration Specifics for JDBC Drivers in Oracle GlassFish Server 3.0.1 Administration Guide.
To use JDBC features, you must choose a JDBC driver to work with the GlassFish Server, then you must set up the driver. This section covers these topics:
Supported JDBC drivers are those that have been fully tested by Oracle. For a list of the JDBC drivers currently supported by the GlassFish Server, see the Oracle GlassFish Server 3.0.1 Release Notes. For configurations of supported and other drivers, see Configuration Specifics for JDBC Drivers in Oracle GlassFish Server 3.0.1 Administration Guide.
Because the drivers and databases supported by the GlassFish Server are constantly being updated, and because database vendors continue to upgrade their products, always check with Oracle technical support for the latest database support information.
To integrate the JDBC driver into a GlassFish Server domain, copy the JAR files into the domain-dir/lib directory, then restart the server. This makes classes accessible to all applications or modules deployed on servers that share the same configuration. For more information about GlassFish Server class loaders, see Chapter 2, Class Loaders.
If you are using an Oracle database with EclipseLink extensions, copy the JAR files into the domain-dir/lib/ext directory, then restart the server. For details, see Oracle Database Enhancements.
The Administration Console detects installed JDBC Drivers automatically when you create a JDBC connection pool. To create a JDBC connection pool using the Administration Console, open the Resources component, open the JDBC component, select Connection Pools, and click on the New button. This displays the New JDBC Connection Pool page.
Based on the Resource Type and Database Vendor you select on the New JDBC Connection Pool page, data source or driver implementation class names are listed in the Datasource Classname or Driver Classname field when you click on the Next button. When you choose a specific implementation class name on the next page, additional properties relevant to the installed JDBC driver are displayed in the Additional Properties section.
When you create a connection pool that uses JDBC technology (a JDBC connection pool) in the GlassFish Server, you can define many of the characteristics of your database connections.
You can create a JDBC connection pool in one of these ways:
In the Administration Console, open the Resources component, open the JDBC component, select Connection Pools, and click on the New button. This displays the New JDBC Connection Pool page. For details, click the Help button in the Administration Console.
Use the asadmin create-jdbc-connection-pool command. For details, see the Oracle GlassFish Server 3.0.1 Reference Manual.
For a complete description of JDBC connection pool features, see the Oracle GlassFish Server 3.0.1 Administration Guide.
In the Administration Console, some JDBC connection pool attributes are advanced, and you cannot set them during JDBC connection pool creation. You can only set them when modifying an existing JDBC connection pool. You can also use the asadmin set command to set or reset a JDBC connection pool's attributes.
You can modify a JDBC connection pool in one of these ways:
In the Administration Console, open the Resources component, open the JDBC component, select Connection Pools, and click on the name of the connection pool you want to modify. This displays the Edit Connection Pool page. To edit advanced attributes, click on the Advanced tab. This displays the Edit Connection Pool Advanced Attributes page. For details, click the Help button in the Administration Console.
Use the asadmin set command. For example:
asadmin set domain1.resources.jdbc-connection-pool.DerbyPool.pooling=false |
For details, see the Oracle GlassFish Server 3.0.1 Reference Manual.
You can test a JDBC connection pool for usability in one of these ways:
In the Administration Console, open the Resources component, open the JDBC component, select Connection Pools, and select the connection pool you want to test. Then select the Ping button in the top left corner of the page. For details, click the Help button in the Administration Console.
Use the asadmin ping-connection-pool command. For details, see the Oracle GlassFish Server 3.0.1 Reference Manual.
Both these commands fail and display an error message unless they successfully connect to the connection pool.
You can also specify that a connection pool is automatically tested when created or reconfigured by setting the Ping attribute to true (the default is false) in one of the following ways:
Enter a Ping value in the New JDBC Connection Pool or Edit Connection Pool page in the Administration Console. For more information, click the Help button in the Administration Console.
Specify the ----ping option in the asadmin create-jdbc-connection-pool command. For more information, see the Oracle GlassFish Server 3.0.1 Reference Manual.
Specify the ping option in the asadmin set command. For example:
asadmin set domain1.resources.jdbc-connection-pool.DerbyPool.ping=true |
For more information, see the Oracle GlassFish Server 3.0.1 Reference Manual.
Flushing a JDBC connection pool recreates all the connections in the pool and brings the pool to the steady pool size without the need for reconfiguring the pool. Connection pool reconfiguration can result in application redeployment, which is a time-consuming operation. Flushing destroys existing connections, and any existing transactions are lost and must be retired.
You can flush a JDBC connection pool in one of these ways:
In the Administration Console, open the Resources component, open the JDBC component, select Connection Pools, and select the connection pool you want to flush. Then select the Flush button in the top left corner of the page. For details, click the Help button in the Administration Console.
Use the asadmin flush-connection-pool command. For details, see the Oracle GlassFish Server 3.0.1 Reference Manual.
A JDBC resource, also called a data source, lets you make connections to a database using getConnection. Create a JDBC resource in one of these ways:
In the Administration Console, open the Resources component, open the JDBC component, and select JDBC Resources. For details, click the Help button in the Administration Console.
Use the asadmin create-jdbc-resource command. For details, see the Oracle GlassFish Server 3.0.1 Reference Manual.