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.

Prequisites:
– 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.

glassfish01

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

glassfish02
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.

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

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

glassfish05

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

glassfish06

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

glassfish07

8. JDBC Resources is created

glassfish08

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…)

Advertisements