Skip navigation

Tag Archives: glassfish

This article will show how to create connection pool and JDBC resource in Glassfish so it can be use in an EJB 3 for database connection. This is Glassfish v2 by the way.

– Place database jdbc lib on $GLASSFISH_HOME/lib

First, start Glassfish ($GLASSFISH_HOME/bin/asadmin start-domain domain-name), then go to admin page

Let’s create connection pool for MySql:
1. Select Resources –> JDBC –> Connection Pools, then click new… button.


2. Enter connection pool name, resource type, and database vendor. then click next.

3. on page 2, scroll down to bottom of the page. And set Additional Properties with your own environtment. Like DatabaseName, User, Password, Port, ServerName, URL, etc. Then click finish.

4. We can see our connection pool we had just create on the list. Click on the connection pool name.

5. Click Ping button to see if the connection is succeed.


6. Now we create JDBC resource using connection pool we had just create. Select Resources –> JDBC –>JDBC Resources, then click New… button


7. Enter JNDI name, Pool name, etc. JNDI name ussualy in format “jdbc/JNDI_NAME”. Then click OK


8. JDBC Resources is created


Now lets test it. to see if the JDBC connection pool and resource we had just created is working. I use EJB 3 on this.

(to be continued…)