Unix sockets
By adding junixsocket you can obtain a socket factory that works with the driver. Code can be found here and instructions here .
Dependencies for junixsocket are :
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-core</artifactId>
<version>2.10.1</version>
<type>pom</type>
</dependency>
Use localhost as the connection host, and add
?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=[path-to-the-unix-socket]
to the connection URL.
For example, if the server listens on /tmp/.s.PGSQL.5432, use:
jdbc:postgresql://localhost/postgres?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/tmp/.s.PGSQL.5432
PostgreSQL normally defaults unix_socket_directories to /tmp, though that
can be changed at build time or in server configuration. Some packaged
installations use /var/run/postgresql, so the socket path may instead be
/var/run/postgresql/.s.PGSQL.5432.