sudo apt-get install postgres postgres-client postgresql-contrib

Download the JDBC driver from https://jdbc.postgresql.org/download.html and then add it to Payara Server by running:



asadmin> add-library /path/to/download/jdbcdriver.jar`

Login to Postgres with the default account by

sudo -i -u postgres

psql

You now need to set a password for the PostgreSQL user on the database. Do so with:

\password postgres

and then enter the new password when prompted.

For full functionality of PostgreSQL, server instrumentation must be enabled, you do this by running the command in Postgres

CREATE EXTENSION adminpack;

You will notice there are two pools already.

Now to create a connection pool. For this tutorial the admin console will be used, but this can be done using asadmin commands or web.xml. The pool name is how the connection pool is to be for this tutorial I will call it postgresqlpool. Set the resource type to javax.sql.DataSource and the database driver vendor to PostgreSQL. Then click Next.

On the next scroll down to the bottom . the following properties in order to be able to connect:







. For more information on connection pools see the blog post here.

Then go to and click on New.

Enter the that you wish to within your applications and set the pool name to be that of the poo set up in the previous step.

@Resource(lookup = "jdbc/postgrespool")