Sunday, November 10, 2013

Creating JDBC Connection Pool in GlassFish Server

Documenting the steps required to create a JDBC data source & connection pool in GlassFish server.

1. Copy the ojdbc*.jar to the following location;
<GLASSFISH_DOMAIN_HOME>/lib/ext

You can find the ojdbc*.jar under the following folder of DB installation;
<DB_HOME>/server/jdbc/lib

Note: Restart your GlassFish server

2. Login as admin user to GlassFish server Admin Console eg., http://localhost:4848/

3. On the home page, choose "Create New JDBC Connection Pool" option. Alternatively, you can also choose Resources -> JDBC -> JDBC Connection Pools from the "Common Tasks" left panel

4. Click "New..." option from the JDBC Connection Pools page

5. Enter the following details in the "General Settings" page

Pool Name: TestPool
Resource Type: javax.sql.DataSource
Database Driver Vendor: Oracle (You can choose appropriate DB vendor here..)

and click "Next"

6. Configure the following "Additional Properties" and leave the other default values

User: DB Username/Schema Name
Database Name: ORCL (SID of your DB connection)
Password: DB Password
URL: jdbc:oracle:thin:@localhost:1521:ORCL
ServerName: localhost
PortNumber: 1521

7. Click Finish

8. In the final page, you can choose to ping the connection to test the connectivity

Lets now create a data source.

9. Go to "JDBC Resources" and choose "New..."

10. Enter a JNDI name (eg., jdbc/test), choose the created connection pool from the list (TestPool) and click on OK.

Now, all your applications deployed on GlassFish server can gain access to your backend via the data source.

2 comments: