Skip navigation

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

About these ads

One Comment

  1. Thank You! I was able to successfully ping my connection pool


One Trackback/Pingback

  1. [...] eingeben während Glassfish läuft. Eine gute Anleitung zur Hochzeit findet man hier und [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: