Class PostgreSqlJdbc

java.lang.Object
de.chojo.sadu.core.jdbc.JdbcConfig<T>
de.chojo.sadu.core.jdbc.RemoteJdbcConfig<PostgreSqlJdbc>
de.chojo.sadu.postgresql.jdbc.PostgreSqlJdbc

public class PostgreSqlJdbc extends de.chojo.sadu.core.jdbc.RemoteJdbcConfig<PostgreSqlJdbc>
A builder to create a PostgreSQL jdbc url.
  • Constructor Details

    • PostgreSqlJdbc

      public PostgreSqlJdbc()
  • Method Details

    • driver

      public String driver()
      Specified by:
      driver in class de.chojo.sadu.core.jdbc.JdbcConfig<PostgreSqlJdbc>
    • withConfig

      public PostgreSqlJdbc withConfig(de.chojo.sadu.core.configuration.DatabaseConfig config)
      Overrides:
      withConfig in class de.chojo.sadu.core.jdbc.RemoteJdbcConfig<PostgreSqlJdbc>
    • connectTimeout

      public PostgreSqlJdbc connectTimeout(int millis)
      The connection timeout value, in milliseconds, or zero for no timeout. Default: 30 000.
      Parameters:
      millis - milliseconds
      Returns:
      builder instance
    • ssl

      public PostgreSqlJdbc ssl(boolean ssl)
      Connect using SSL. The server must have been compiled with SSL support. This property does not need a value associated with it. The mere presence of it specifies a SSL connection. However, for compatibility with future versions, the value "true" is preferred. For more information see Chapter 4, Using SSL.
      Parameters:
      ssl - ssl mode.
      Returns:
      builder instance
    • sslFactory

      public PostgreSqlJdbc sslFactory(String sslFactory)
      The provided value is a class name to use as the SSLSocketFactory when establishing a SSL connection. For more information see the section called Custom SSLSocketFactory”. defaults to LibPQFactory
      Parameters:
      sslFactory - ssl factory.
      Returns:
      builder instance
    • sslMode

      public PostgreSqlJdbc sslMode(PostgreSqlJdbc.SslMode sslMode)
      Enables SSL/TLS in a specific mode.

      This option replaces the deprecated options: disableSslHostnameVerification, trustServerCertificate, useSsl

      Parameters:
      sslMode - ssl mode. Default PostgreSqlJdbc.SslMode.PREFER
      Returns:
      builder instance
    • sslcert

      public PostgreSqlJdbc sslcert(String path)
      Provide the full path for the certificate file. Defaults to /defaultdir/postgresql.crt, where defaultdir is ${user.home}/.postgresql/ in *nix systems and %appdata%/postgresql/ on Windows.

      It can be a PEM encoded X509v3 certificate

      Note: This parameter is ignored when using PKCS-12 keys, since in that case the certificate is also retrieved from the same keyfile.

      Parameters:
      path - vert path
      Returns:
      builder instance
    • sslkey

      public PostgreSqlJdbc sslkey(String path)
      Provide the full path for the key file. Defaults to /defaultdir/postgresql.pk8.

      Note: The key file must be in PKCS-12 or in PKCS-8 DER format. A PEM key can be converted to DER format using the openssl command:

      Parameters:
      path - path
      Returns:
      builder instance
    • sslrootcert

      public PostgreSqlJdbc sslrootcert(String sslrootcert)
      File name of the SSL root certificate. Defaults to defaultdir/root.crt

      It can be a PEM encoded X509v3 certificate

      Parameters:
      sslrootcert - sslrootcert
      Returns:
      builder instance
    • sslhostnameverifier

      public PostgreSqlJdbc sslhostnameverifier(String sslhostnameverifier)
      Class name of hostname verifier. Defaults to using org.postgresql.ssl.PGjdbcHostnameVerifier
      Parameters:
      sslhostnameverifier - sslhostnameverifier
      Returns:
      builder instance
    • sslpasswordcallback

      public PostgreSqlJdbc sslpasswordcallback(String sslpasswordcallback)
      Class name of the SSL password provider. Defaults to org.postgresql.ssl.jdbc4.LibPQFactory.ConsoleCallbackHandler
      Parameters:
      sslpasswordcallback - sslpasswordcallback
      Returns:
      builder instance
    • sslpassword

      public PostgreSqlJdbc sslpassword(int sslpassword)
      If provided will be used by ConsoleCallbackHandler
      Parameters:
      sslpassword - sslpassword
      Returns:
      builder instance
    • allowMultiQueries

      public PostgreSqlJdbc allowMultiQueries(boolean state)
      Allow multi-queries like insert into ab (i) values (1); insert into ab (i) values
      Parameters:
      state - state. Default: false
      Returns:
      builder instance
    • allowMultiQueries

      public PostgreSqlJdbc allowMultiQueries()
      Allow multi-queries like insert into ab (i) values (1); insert into ab (i) values
      Returns:
      builder instance
    • dumpQueriesOnException

      public PostgreSqlJdbc dumpQueriesOnException(boolean state)
      If set to 'true', an exception is thrown during query execution containing a query string.
      Parameters:
      state - state. Default: false
      Returns:
      builder instance
    • addParameter

      public <V> PostgreSqlJdbc addParameter(String key, V value)
      Overrides:
      addParameter in class de.chojo.sadu.core.jdbc.JdbcConfig<PostgreSqlJdbc>
      See Also:
    • currentSchema

      public PostgreSqlJdbc currentSchema(String... schemas)
      Specify the schema or several schema to be set in the search-path. This schema will be used to resolve unqualified object names used in statements over this connection.
      Parameters:
      schemas - default schemas
      Returns:
      builder instance
    • currentSchema

      public PostgreSqlJdbc currentSchema(String schema)
      Specify the schema or several schema to be set in the search-path. This schema will be used to resolve unqualified object names used in statements over this connection.
      Parameters:
      schema - the default schema
      Returns:
      builder instance
    • applicationName

      public PostgreSqlJdbc applicationName(String applicationName)
      Specifies the name of the application that is using the connection. This allows a database administrator to see what applications are connected to the server and what resources they are using through views like pgstatactivity.
      Parameters:
      applicationName - application name
      Returns:
      builder instance
    • defaultDriverClass

      protected String defaultDriverClass()
      Specified by:
      defaultDriverClass in class de.chojo.sadu.core.jdbc.JdbcConfig<PostgreSqlJdbc>