Because Java only uses TCP/IP connections, the PostgreSQL™ server must be configured to accept TCP/IP connections. This can be done by setting tcpip_socket = true in the postgresql.conf file or by supplying the -i option flag when starting postmaster.
Also, the client authentication setup in the pg_hba.conf file may need to be configured. Refer to the PostgreSQL documentation for details. The JDBC driver supports the trust, ident, password, md5, and crypt authentication methods.