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