JDBC Connection Pools in Glassfish

Guest Author

I've been attempting to configure Glassfish for ADF 11g and the need arose to create a jdbc connection pool to my Oracle XE 11g database. While this is really very trivial there were no samples of how to do this and documentation, while good, rarely ever provides concrete examples. After fumbling around for a few minutes searching for an example I gave up and figured it out on my own. Here are the steps for any of you that may be in need.

This can be done either via the Glassfish command line tool asadmin or through the admin console. I'm doing this through the admin console.

  • Start Glassfish and connect to the admin console with the credentials you defined at installation: http://localhost:4848
  • Navigate to Resources | JDBC | JDBC Connection Pools and select New. Be sure to enter Resource Type & Datasource Classname under General Settings tab. You can go with the defaults for Pool Settings etc... View Image
  • Go to the Additional Properties tab and create username, password, and url properties with the respective values. View Image
  • Navigate to Resources | JDBC | JDBC Resources and select New. Be sure to enter the JNDI Name and select the Pool Name for the jdbc connection pool you created previously. View Image
  • Navigate to Configurations | server-config | JVM Settings and select the JVM Options tab. Add the values highlighted: -Doracle.jdbc.J2EE13Compliant=true is used to make sure the driver behaves in a JEE-compliant manner. View Image
  • To integrate the JDBC driver into a GlassFish Server domain, copy the JAR files into the domain-dir/lib directory, then restart the server. The JAR file for the Oracle 11 database driver is ojdbc6dms.jar.
    • Note: You can also use the glassfish provided jdbc driver oracle.jdbc.drivers/ojdbc6.jar. This is sufficient to copy into the lib directory.
  • Last thing, once you've configured your datasource, is to test it out. You can invoke a ping from the JDBC Connection Pool console to validate the db connection setup.

This is the datasource you will use for ADF Essentials that just went live today (09/24/2012) so download the new ADF Essentials now! You will have to take a short survey prior to downloading the new ADF Essentials.

See Shay's blog on Deploying ADF Essentials Applications to Glassfish.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.