Glassfish 4 and Postgresql 9.3 driver

Today I configured another development stend for our team. This time I added Postgresql 9.3 ODBC driver support to our Glassfish 4 server. What should I do to repeat this actions:

Put Postgresql driver to Glassfish domain lib folder

This link contains the latest PostgreSql driver: http://jdbc.postgresql.org/download.html  I got the postgresql-9.3-1100.jdbc41 one. 
Copy downloaded driver to GLASSFISH_HOME/domains/YOUR_DOMAIN/lib, for example to /opt/glassfish4/domains/domain1/lib
Restart Glassfish

Create Connection Pool in Glassfish

Open Glassfish administration console in browser. Go to Resources-JDBC-JDBC Connection Pool and  press New button.
Fill Pool Name with your new pool name, set Resource Type to javax.sql.ConnectionPoolDataSource and Database Driver Vendor to Postgresql. Press Next and see Properties Editor
Leave and fill only User, DatabaseName, ServerName, PortNumber properties. Remove others by selecting them and pressing RemoveAll button above the grid. Press Finish button below.
The new pool has appeared in left menu. Select it and press Ping button in General Tab to check the connection. Fix property values if ping is not successful.

Create JDBC Resource in Glassfish

In Glassfish administration go to Resources-JDBC-JDBC Resources and press New button. Enter JNDI Name like jdbc/my-database-name, choose your pool in drop down and save changes. Now we can refer the database from persistence xml in our application.


 

3 thoughts on “Glassfish 4 and Postgresql 9.3 driver

  1. ipaddr

    Hi, this is very nice info.

    Did you got extention name like jdbc/{jndi_name}_pm?

    if you can solve it, could you shared the solution with me

     

    thank you

    Reply
  2. Daniel

    Hi Dimitri,

    thank you for this manual. Beside User, DatabaseName, ServerName and PortNumber also “Password” attribute is needed.

    Best regards,
    Daniel

    Reply

Leave a Reply to ipaddr Cancel reply

Your email address will not be published.