Quantcast
Channel: Marios' Java Programming Experience Corner
Viewing all articles
Browse latest Browse all 25

Create Postgresql Connection Pool in Glassfish 2.x.x

$
0
0
We will create a PostgreSQL (8.4) Connection Pool on a GlassFish 2.1.1 [and GlassFish v3].

First of all, we need to download the latest jdbc driver:

http://jdbc.postgresql.org/download.html

Copy the downloaded archive postgresql-x.x.-xxx.jdbc4.jar in {glassfish}/lib directory and restart glassfish:

asadmin stop-domain domain1
asadmin start-domain domain1

Now we need to navigate to the administrator application:
http://localhost:4848/
 
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.
Fill in the Connection Pool 'Name'.
Select 'Resource Type' : 'javax.sql.DataSource'.
Select 'Database Vendor' : 'PostgreSQL'.
Select 'Next'.

At the next page go down at the additional Properties.
Find and edit the following properties :
Select 'Name' : 'User' and 'Value' : {db_user}
Select 'Name' : 'Password' and 'Value' : {db_user_pass}
Select 'Name' : 'DatabaseName' and 'Value' : {db_name}
Select 'Name' : 'ServerName' and 'Value' : {server_hostname}
If your dqatabase is not in the default port (5432) you might also need to edit the following attribute :
Select 'Name' : 'PortNumber' and 'Value' : {port_number}
Select 'Finish'.

Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.

Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we just created.
And select 'OK'.

The Connection Pool is ready!

P.S.
If you had any problems creating the pool, send me a message and I'll reply as soon as possible.

Viewing all articles
Browse latest Browse all 25

Trending Articles