Astuces

De Wiki de Jordan LE NUFF
Sauter à la navigation Sauter à la recherche

Présentation

Cette page a pour objet de regrouper différentes astuces liées à l'utilisation de PostgreSQL.

Connecteur JDBC et socket Unix

Pour se connecter à PostgreSQL via un socket Unix au travers d'un connecteur JDBC, suivre la recommandation officielle de PostgreSQL dans sa documentation :

Aleksander Blomskøld has forked junixsocket and added a Unix SocketFactory that works with the driver. His code can be found at https://github.com/fiken/junixsocket.

Dependencies for junixsocket are :

<dependency>
  <groupId>no.fiken.oss.junixsocket</groupId>
  <artifactId>junixsocket-common</artifactId>
  <version>1.0.2</version>
</dependency>
<dependency>
  <groupId>no.fiken.oss.junixsocket</groupId>
  <artifactId>junixsocket-native-common</artifactId>
  <version>1.0.2</version>
</dependency>

Simply add ?socketFactory=org.newsclub.net.unix.socketfactory.PostgresqlAFUNIXSocketFactory&socketFactoryArg=[path-to-the-unix-socket] to the connection URL.

For many distros the default path is /var/run/postgresql/.s.PGSQL.5432[1]

Références

  1. Extrait de la documenation officiel de PostgreSQL : https://jdbc.postgresql.org/documentation/head/connect.html#unix%20sockets