Home > Support > HOWTO List > Accessing Postgresql via JDBC

Accessing Postgresql via JDBC

For PostgreSQL 7.X, in /var/lib/pgsql/data/postgresql.conf set:

tcpip_socket = true

For PostgreSQL 8.X, see

This permits access to postgresql using sockets rather than Linux socket files.

In /var/lib/pgsql/data/pg_hba.conf, uncomment:

host    all         all   trust

This allows clients on the server to connect to the postgresql server.

The postgresql connection url is decribed at:

For example: jdbc:postgresql://host:port/database (host defaults to localhost, port defaults to 5432).

A quick bit of code to test your connectivity would be something like:

Connection c = DriverManager.getConnection("jdbc:postgresql:dbname", "username", "password"); 
System.out.println("Connected OK");