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