- Creating a Connection Pool to PostgreSQL on Glassfish V3
- 12 Administering Database Connectivity
- About Database Connectivity
- Setting Up the Database
- To Install the Database and Database Driver
- To Start the Database
- To Stop the Database
- Java DB Utility Scripts
- To Configure Your Environment to Run Java DB Utility Scripts
- Configuring Access to the Database
- Administering JDBC Connection Pools
- To Create a JDBC Connection Pool
- To List JDBC Connection Pools
- To Contact (Ping) a Connection Pool
- To Reset (Flush) a Connection Pool
- To Update a JDBC Connection Pool
- To Delete a JDBC Connection Pool
- Configuring Specific JDBC Connection Pool Features
- Administering JDBC Resources
- To Create a JDBC Resource
- To List JDBC Resources
- To Update a JDBC Resource
- To Delete a JDBC Resource
- Enabling the jdbc/__default Resource in a Clustered Environment
- To Enable the jdbc/__default Resource for a Clustered Environment
- Integrating the JDBC Driver
- Supported Database Drivers
- Making the JDBC Driver JAR Files Accessible
- Automatic Detection of Installed Drivers
- Configuration Specifics for JDBC Drivers
Creating a Connection Pool to PostgreSQL on Glassfish V3
I recently created a new connection pool to PostgreSQL on Glassfish and I would like to share the steps I followed with you. Obviously, you need PostgreSQL and Glassfish installed on your machine and a database already created in PostgreSQL. If you didn’t configure your new PostgreSQL installation yet, follow the steps I described at this previous post and come back here to continue with the connection pool. The necessary steps are:
We need the PostgreSQL JDBC Driver, since Glassfish and its deployed applications are writen in Java. Drivers are available for download at http://jdbc.postgresql.org. For this experiment choose the JDBC4 driver.
Download the driver file postgresql- .jdbc4.jar and copy it to the diretory [glassfish_home]/glassfish/domains/domain1/lib/ .
Restart Glassfish in order to make it load the new database driver. I thought that adopting an OSGI architecture Glassfish would never need restarts again, but I was wrong. At least, the restarting process is faster than V2.
Enter in the administration console and go to Resources/JDBC/Connection Pools .
Create a new connection pool with the name [database_name]Pool , select the resource type javax.sql.ConnectionPoolDataSource , select the database vendor PostgreSQL and click next.
Select the datasource classname org.postgresql.ds.PGConnectionPoolDataSource and inform the following additional properties:
DatabaseName=[database-name]
Password=*******
PortNumber=5432 (this is the default port but make sure that you are using the correct one)
ServerName=[server-name|ip]
User= .
Click “Finish” to save the new connection pool.
Go to the list of connection pools again and select the new one that you just created.
Click on “Ping” to check if the connection was correctly configured. The message “Ping Succeeded” means that the connection is working fine.
In order to be able to use this connection pool in JEE applications, we have to create a JNDI name for it:
Go to Resources/JDBC/JDBC Resources .
Click on “New” and set the JNDI Name jdbc/[database_name] , select the connection pool created above and click “Ok” to finish. This JNDI name will be used by applications to access the PostgreSQL database.
These instructions may work with Glassfish V2 as well, since its database configuration is quite similar.
I’m being very specific in terms of chosen technologies, but if you have a slightly different configuration and these steps are not working yet, please comment your issues below, describing also your current configuration/context. Maybe, we can figure it out.
12 Administering Database Connectivity
This chapter provides procedures for performing database connectivity tasks in the Oracle GlassFish Server 3.1.2 environment by using the asadmin command-line utility.
The following topics are addressed here:
Instructions for accomplishing these tasks by using the Administration Console are contained in the Administration Console online help.
About Database Connectivity
A database management system (DBMS) provides facilities for storing, organizing, and retrieving data. The information in databases is often described as persistent data because it is saved on disk and exists after the application process ends. Most business applications store data in relational databases. Applications can access database information by using the Java Database Connectivity (JDBC) API.
The key elements of database connectivity are the following:
Database. The repository where data is stored for an enterprise. Java EE applications access relational databases through the JDBC API. For administration procedures, see Setting Up the Database.
JDBC Connection Pool. A JDBC connection pool is a group of reusable connections for a particular database. For administration procedures, see Administering JDBC Connection Pools.
JDBC Resource. A JDBC resource (data source) provides applications with a means of connecting to a database. 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 resource is identified by its Java Naming and Directory Interface (JNDI) name. For administration procedures, see Administering JDBC Resources.
JDBC Driver. A database driver is a software component that enables a Java application to interact with a database connectivity API . Each database requires its own driver. For administration procedures, see Integrating the JDBC Driver.
At runtime, the following sequence occurs when an application connects to a database:
The application gets the JDBC resource associated with the database by making a call through the JNDI API.
Using the JNDI name of the resource, the naming and directory service locates the JDBC resource. Each JDBC resource specifies a connection pool.
Using the JDBC resource, the application gets a database connection.
GlassFish 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.
After the database connection is established, the application can read, modify, and add data to the database.
The application accesses 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.
When the application is finished accessing the database, the application closes the connection and returns the connection to the connection pool.
Setting Up the Database
Most applications use relational databases to store, organize, and retrieve data. Applications access relational databases through the Java Database Connectivity (JDBC) API.
The following topics are addressed here:
To Install the Database and Database Driver
Install a supported database product.
To see the current list of database products supported by GlassFish Server, refer to the Oracle GlassFish Server Release Notes .
Install a supported JDBC driver for the database product.
For a list of drivers supported by GlassFish Server, see Configuration Specifics for JDBC Drivers.
Make the JDBC driver JAR file accessible to the domain administration server (DAS).
Create the database.
The application provider usually delivers scripts for creating and populating the database.
You are now ready to create a connection pool for the database, and a JDBC resource that points to the connection pool. See To Create a JDBC Connection Pool and To Create a JDBC Resource. The final step is to integrate the JDBC driver into an administrative domain as described in Integrating the JDBC Driver.
To Start the Database
GlassFish Server includes an implementation of Java DB (formerly known as Derby), however, you can use any JDBC-compliant database. The database is not started automatically when you start GlassFish Server, so if you have applications that require a database, you need to start Java DB manually by using the local start-database subcommand.
Start the database by using the start-database subcommand.
When the database server starts, or a client connects to it successfully, the following files are created at the location that is specified by the —dbhome option:
The derby.log file contains the database server process log along with its standard output and standard error information.
The database files contain your schema (for example, database tables).
Example 12-1 Starting a Database
This example starts Derby on the host host1 and port 5001.
You can also view the full syntax and options of the subcommand by typing asadmin help start-database at the command line.
To Stop the Database
Use the local stop-database subcommand to stop Java DB on a specified port. A single host can have multiple database server processes running on different ports.
If necessary, notify users that the database is being stopped.
Stop the database by using the stop-database subcommand.
Example 12-2 Stopping a Database
This example stops Java DB on port 5001 of localhost .
For a laptop that roams between networks, you might have trouble shutting down the database. If you start Java DB and then change your IP address, you will not be able to stop Java DB unless you add a specific —dbhost argument. For example, if you run asadmin start-database dbhost = 0.0.0.0 , and then disconnect Ethernet and switch to wifi, you should run a command similar to the following to stop the database:
asadmin stop-database dbhost localhost
You can also view the full syntax and options of the subcommand by typing asadmin help stop-database at the command line.
Java DB Utility Scripts
The Java DB configuration that is available for use with GlassFish Server includes scripts that can help you use Java DB. The following scripts are available in the as-install /javadb/frameworks/NetworkServer/bin directory:
Script to start the network server
Script to stop the network server
Interactive JDBC scripting tool
Script to view all or part of the DDL for a database
Script to display versioning information about the Java DB environment
Script to execute commands on the NetworkServerControl API
To Configure Your Environment to Run Java DB Utility Scripts
Ensure that the JAVA_HOME environment variable specifies the directory where the JDK is installed.
Set the JAVADB_HOME environment variable to point to the as-install /derby directory.
For more information about these utilities, see the following documentation:
Configuring Access to the Database
After establishing the database, you are ready to set up access for GlassFish Server applications. The high-level steps include creating a JDBC connection pool, creating a JDBC resource for the connection pool, and integrating a JDBC driver into an administrative domain.
Instructions for performing these steps are contained in the following sections:
Administering JDBC Connection Pools
A JDBC connection pool is a group of reusable connections for a particular database. Because creating each new physical connection is time consuming, GlassFish Server maintains a pool of available connections. 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. JDBC connection pools can be globally accessible or be scoped to an enterprise application, web module, EJB module, connector module or application client module, as described in «Application-Scoped Resources» in Oracle GlassFish Server Application Deployment Guide .
A JDBC resource is created by specifying the connection pool with which the resource is associated. Multiple JDBC resources can specify a single connection pool. The properties of connection pools can vary with different database vendors. Some common properties are the database name (URL), the user name, and the password.
The following tasks and information are used to administer JDBC connection pools:
To Create a JDBC Connection Pool
Use the create-jdbc-connection-pool subcommand in remote mode to register a new JDBC connection pool with the specified JDBC connection pool name. A JDBC connection pool or a connector connection pool can be created with authentication. You can either use a subcommand option to specify user, password, or other connection information using the asadmin utility, or specify the connection information in the XML descriptor file.
One connection pool is needed for each database, possibly more depending on the application. When you are building the connection pool, certain data specific to the JDBC driver and the database vendor is required. You can find some of the following specifics inConfiguration Specifics for JDBC Drivers:
Database vendor name
Resource type, such as javax.sql.DataSource (local transactions only) javax.sql.XADataSource (global transactions)
Data source class name
Required properties, such as the database name (URL), user name, and password
Creating a JDBC connection pool is a dynamic event and does not require server restart. However, there are some parameters that do require server restart. See Configuration Changes That Require Restart.
Before You Begin
Before creating the connection pool, you must first install and integrate the database and its associated JDBC driver. For instructions, see Setting Up the Database.
Ensure that the server is running.
Remote subcommands require a running server.
Create the JDBC connection pool by using the create-jdbc-connection-pool subcommand.
If needed, restart the server.
Some parameters require server restart. See Configuration Changes That Require Restart.
Example 12-3 Creating a JDBC Connection Pool
This example creates a JDBC connection pool named sample_derby_pool on localhost .
You can also view the full syntax and options of the subcommand by typing asadmin help create-jdbc-connection-pool at the command line.
To List JDBC Connection Pools
Use the list-jdbc-connection-pools subcommand in remote mode to list all existing JDBC connection pools.
Ensure that the server is running.
Remote subcommands require a running server.
List the JDBC connection pools by using the list-jdbc-connection-pools subcommand.
Example 12-4 Listing JDBC Connection Pools
This example lists the JDBC connection pools that are on localhost .
You can also view the full syntax and options of the subcommand by typing asadmin help list-jdbc-connection-pools at the command line.
To Contact (Ping) a Connection Pool
Use the ping-connection-pool subcommand in remote mode to test if a connection pool is usable. For example, if you create a new JDBC connection pool for an application that is expected to be deployed later, you can test the JDBC pool with this subcommand before the application is deployed. Running a ping will force the creation of the pool if it hasn’t already been created.
Before You Begin
Before you can contact a connection pool, the connection pool must be created with authentication, and the server or database must be running.
Ensure that the server is running.
Remote subcommands require a running server.
Ping a connection pool by using the ping-connection-pool subcommand.
Example 12-5 Contacting a Connection Pool
This example tests to see if the DerbyPool connection pool is usable.
You can also view the full syntax and options of the subcommand by typing asadmin help ping-connection-pool at the command line.
You can also specify that a JDBC connection pool is automatically tested when created or reconfigured by setting its —ping option to true (the default is false ). See To Create a JDBC Connection Pool or To Update a JDBC Connection Pool.
To Reset (Flush) a Connection Pool
Use the flush-connection-pool in remote mode to reinitialize all connections established in the specified connection pool without the need for reconfiguring the pool. Connection pool reconfiguration can result in application redeployment, which is a time-consuming operation. The JDBC connection pool or connector connection pool is reset to its initial state. Any existing live connections are destroyed, which means that the transactions associated with these connections are lost and must be retried. The subcommand then recreates the initial connections for the pool, and restores the pool to its steady pool size.
Ensure that the server is running.
Remote subcommands require a running server.
Reset a connection pool by using the flush-connection-pool subcommand.
Example 12-6 Resetting (Flushing) a Connection Pool
This example resets the JDBC connection pool named __TimerPool to its steady pool size.
You can also view the full syntax and options of the subcommand by typing asadmin help flush-connection-pool at the command line.
To Update a JDBC Connection Pool
You can change all of the settings for an existing pool except its name. Use the get and set subcommands to view and change the values of the JDBC connection pool properties.
List the JDBC connection pools by using the list-jdbc-connection-pools subcommand.
View the attributes of the JDBC connection pool by using the get subcommand.
Set the attribute of the JDBC connection pool by using the set subcommand.
If needed, restart the server.
Some parameters require server restart. See Configuration Changes That Require Restart.
For information about how to tune a connection pool, see the Oracle GlassFish Server Performance Tuning Guide .
To Delete a JDBC Connection Pool
Use the delete-jdbc-connection-pool subcommand in remote mode to delete an existing JDBC connection pool. Deleting a JDBC connection pool is a dynamic event and does not require server restart.
Before You Begin
Before deleting a JDBC connection pool, all associations to the resource must be removed.
Ensure that the server is running.
Remote subcommands require a running server.
List the JDBC connection pools by using the list-jdbc-connection-pools subcommand.
If necessary, notify users that the JDBC connection pool is being deleted.
Delete the connection pool by using the delete-jdbc-connection-pool subcommand.
Example 12-7 Deleting a JDBC Connection Pool
This example deletes the JDBC connection pool named DerbyPool .
You can also view the full syntax and options of the subcommand by typing asadmin help delete-jdbc-connection-pool at the command line.
Configuring Specific JDBC Connection Pool Features
In GlassFish Server, JDBC Connection Pools support a variety of features to simplify administration, monitoring and performance tuning. The following topics address several of these features:
Transparent Pool Reconfiguration
When the properties or attributes of a JDBC connection pool are changed, the connection pool is destroyed and re-created. Normally, applications using the connection pool must be redeployed as a consequence. This restriction can be avoided by enabling transparent JDBC connection pool reconfiguration. When this feature is enabled, applications do not need to be redeployed. Instead, requests for new connections are blocked until the reconfiguration operation completes. Connection requests from any in-flight transactions are served using the old pool configuration so as to complete the transaction. Then, connections are created using the pool’s new configuration, and any blocked connection requests are served with connections from the re-created pool.
To enable transparent JDBC connection pool reconfiguration, set the dynamic-reconfiguration-wait-timeout-in-seconds property of the JDBC connection pool to a positive, nonzero value in one of the following ways:
Add it as a property in the Edit JDBC Connection Pool Properties page in the Administration Console. For more information, click the Help button in the Administration Console.
Specify it using the —property option in the create-jdbc-connection-pool subcommand. For more information, see create-jdbc-connection-pool (1).
Set it using the set subcommand. For example:
This property specifies the time in seconds to wait for in-use connections to close and in-flight transactions to complete. Any connections in use or transaction in flight past this time must be retried.
Using an Initialization Statement
You can specify a statement that executes each time a physical connection to the database is created (not reused) from a JDBC connection pool. This is useful for setting request or session specific properties and is suited for homogeneous requests in a single application. Set the Init SQL attribute of the JDBC connection pool to the SQL string to be executed in one of the following ways:
Enter an Init SQL value in the Edit Connection Pool Advanced Attributes page in the Administration Console. For more information, click the Help button in the Administration Console.
Specify the —initsql option in the asadmin create-jdbc-connection-pool command. For more information, see create-jdbc-connection-pool (1).
Specify the init-sql option in the asadmin set command. For example:
Setting a Statement Timeout
An abnormally long running JDBC query executed by an application may leave it in a hanging state unless a timeout is explicitly set on the statement. Setting a statement timeout guarantees that all queries automatically time out if not completed within the specified period. When statements are created, the queryTimeout is set according to the statement timeout setting. This works only when the underlying JDBC driver supports queryTimeout for Statement , PreparedStatement , CallableStatement , and ResultSet .
You can specify a statement timeout in the following ways:
Enter a Statement Timeout value in the Edit Connection Pool Advanced Attributes page in the Administration Console. For more information, click the Help button in the Administration Console.
Specify the —statementtimeout option in the asadmin create-jdbc-connection-pool command. For more information, see create-jdbc-connection-pool (1).
Statement Leak Detection and Leaked Statement Reclamation
If statements are not closed by an application after use, it is possible for the application to run out of cursors. Enabling statement leak detection causes statements to be considered as leaked if they are not closed within a specified period. Additionally, leaked statements can reclaimed automatically.
To enable statement leak detection, set Statement Leak Timeout In Seconds for the JDBC connection pool to a positive, nonzero value in one of the following ways:
Specify the —statementleaktimeout option in the create-jdbc-connection-pool subcommand. For more information, see create-jdbc-connection-pool (1).
Specify the statement-leak-timeout-in-seconds option in the set subcommand. For example:
When selecting a value for Statement Leak Timeout In Seconds, make sure that:
It is less than the Connection Leak Timeout; otherwise, the connection could be closed before the statement leak is recognized.
It is greater than the Statement Timeout; otherwise, a long running query could be mistaken as a statement leak.
After enabling statement leak detection, enable leaked statement reclamation by setting Reclaim Leaked Statements for the JDBC connection pool to a true value in one of the following ways:
Specify the —statementleakreclaim=true option in the create-jdbc-connection-pool subcommand. For more information, see create-jdbc-connection-pool (1).
Specify the statement-leak-reclaim option in the set subcommand. For example:
Statement Caching
Statement caching stores statements, prepared statements, and callable statements that are executed repeatedly by applications in a cache, thereby improving performance. Instead of the statement being prepared each time, the cache is searched for a match. The overhead of parsing and creating new statements each time is eliminated.
Statement caching is usually a feature of the JDBC driver. The GlassFish Server provides caching for drivers that do not support caching. To enable this feature, set the Statement Cache Size for the JDBC connection pool in one of the following ways:
Enter a Statement Cache Size value in the Edit Connection Pool Advanced Attributes page in the Administration Console. For more information, click the Help button in the Administration Console.
Specify the —statementcachesize option in the asadmin create-jdbc-connection-pool command. For more information, see create-jdbc-connection-pool (1).
Specify the statement-cache-size option in the asadmin set command. For example:
By default, this attribute is set to zero and the statement caching is turned off. To enable statement caching, you can set any positive nonzero value. The built-in cache eviction strategy is LRU-based (Least Recently Used). When a connection pool is flushed, the connections in the statement cache are recreated.
Statement Tracing
You can trace the SQL statements executed by applications that use a JDBC connection pool. Set the SQL Trace Listeners attribute to a comma-separated list of trace listener implementation classes in one of the following ways:
Enter an SQL Trace Listeners value in the Edit Connection Pool Advanced Attributes page in the Administration Console. For more information, click the Help button in the Administration Console.
Specify the —sqltracelisteners option in the asadmin create-jdbc-connection-pool command. For more information, see create-jdbc-connection-pool (1).
Specify the sql-trace-listeners option in the asadmin set command. For example:
The GlassFish Server provides a public interface, org.glassfish.api.jdbc.SQLTraceListener , that implements a means of recording SQLTraceRecord objects. To make custom implementations of this interface available to the GlassFish Server, place the implementation classes in as-install /lib .
The GlassFish Server provides an SQL tracing logger to log the SQL operations in the form of SQLTraceRecord objects in the server.log file. The module name under which the SQL operation is logged is javax.enterprise.resource.sqltrace . SQL traces are logged as FINE messages along with the module name to enable easy filtering of the SQL logs. A sample SQL trace record looks like this:
This trace shows that an executeUpdate(String sql, String columnNames) operation is being done.
When SQL statement tracing is enabled and JDBC connection pool monitoring is enabled, GlassFish Server maintains a tracing cache of recent queries and their frequency of use. The following JDBC connection pool properties can be configured to control this cache and the monitoring statistics available from it:
Specifies how long in minutes to keep a query in the tracing cache, tracking its frequency of use. The default value is 5 minutes.
Specifies how many of the most used queries, in frequency order, are listed the monitoring report. The default value is 10 queries.
Set these parameters in one of the following ways:
Add them as properties in the Edit JDBC Connection Pool Properties page in the Administration Console. For more information, click the Help button in the Administration Console.
Specify them using the —property option in the create-jdbc-connection-pool subcommand. For more information, see create-jdbc-connection-pool (1).
Set them using the set subcommand. For example:
Administering JDBC Resources
A JDBC resource, also known as a data source, provides an application with a means of connecting to a database. Typically, you create a JDBC resource for each database that is accessed by the applications deployed in a domain. Multiple JDBC resources can be specified for a database. JDBC resources can be globally accessible or be scoped to an enterprise application, web module, EJB module, connector module or application client module, as described in «Application-Scoped Resources» in Oracle GlassFish Server Application Deployment Guide .
A JDBC resource is created by specifying the connection pool with which the resource will be associated . Use a unique Java Naming and Directory Interface (JNDI) name to identify the resource. For example, the JNDI name for the resource of a payroll database might be java:comp/env/jdbc/payrolldb .
The following tasks and information are used to administer JDBC resources:
To Create a JDBC Resource
Use the create-jdbc-resource subcommand in remote mode to create a JDBC resource. Creating a JDBC resource is a dynamic event and does not require server restart.
Because all JNDI names are in the java:comp/env subcontext, when specifying the JNDI name of a JDBC resource in the Administration Console, use only the jdbc/ name format. For example, a payroll database might be specified as jdbc/payrolldb .
Before You Begin
Before creating a JDBC resource, you must first create a JDBC connection pool. For instructions, see To Create a JDBC Connection Pool.
Ensure that the server is running.
Remote subcommands require a running server.
Create a JDBC resource by using the create-jdbc-resource subcommand.
Information about properties for the subcommand is included in this help page.
If necessary, notify users that the new resource has been created.
Example 12-8 Creating a JDBC Resource
This example creates a JDBC resource named DerbyPool .
You can also view the full syntax and options of the subcommand by typing asadmin help create-jdbc-resource at the command line.
To List JDBC Resources
Use the list-jdbc-resources subcommand in remote mode to list the existing JDBC resources.
Ensure that the server is running.
Remote subcommands require a running server.
List JDBC resources by using the list-jdbc-resources subcommand.
Example 12-9 Listing JDBC Resources
This example lists JDBC resources for localhost .
You can also view the full syntax and options of the subcommand by typing asadmin help list-jdbc-resources at the command line.
To Update a JDBC Resource
You can enable or disable a JDBC resource by using the set subcommand. The JDBC resource is identified by its dotted name.
List JDBC resources by using the list-jdbc-resources subcommand.
Modify the values for the specified JDBC resource by using the set subcommand.
Example 12-10 Updating a JDBC Resource
This example changes the res1 enabled setting to false.
To Delete a JDBC Resource
Use the delete-jdbc-resource subcommand in remote mode to delete an existing JDBC resource. Deleting a JDBC resource is a dynamic event and does not require server restart.
Before You Begin
Before deleting a JDBC resource, all associations with this resource must be removed.
Ensure that the server is running.
Remote subcommands require a running server.
List JDBC resources by using the list-jdbc-resources subcommand.
If necessary, notify users that the JDBC resource is being deleted.
Delete a JDBC resource by using the delete-jdbc-resource subcommand.
Example 12-11 Deleting a JDBC Resource
This example deletes a JDBC resource named DerbyPool .
You can also view the full syntax and options of the subcommand by typing asadmin help delete-jdbc-resource at the command line.
Enabling the jdbc/__default Resource in a Clustered Environment
GlassFish Server 3.1.2 includes a preconfigured JDBC resource with the JNDI name jdbc/__default . This jdbc/__default resource is not enabled by default, so you need to explicitly enable it if you want to use it in a cluster.
To Enable the jdbc/__default Resource for a Clustered Environment
Instructions for creating JDBC resources in general are provided in To Create a JDBC Resource. Use the following procedure to enable the preconfigured jdbc/__default resource for a clustered GlassFish Server environment.
Create the jdbc/__default resource reference for the cluster.
Enable the resource on the DAS that manages the cluster.
This step is only required if the cluster includes remote instances.
Restart the DAS and the target cluster(s).
Integrating the JDBC Driver
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 Database Drivers
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 Release Notes . For configurations of supported and other drivers, see Configuration Specifics for JDBC Drivers.
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.
Making the JDBC Driver JAR Files Accessible
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 «Class Loaders» in Oracle GlassFish Server Application Development Guide .
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» in Oracle GlassFish Server Application Development Guide .
Automatic Detection of Installed Drivers
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.
Configuration Specifics for JDBC Drivers
GlassFish Server is designed to support connectivity to any database management system by using a corresponding JDBC driver. Configuration information is provided for these JDBC drivers: