Additional connection properties v42.5.4.2

In addition to the standard connection parameters, the EDB Postgres Advanced Server JDBC driver supports connection properties that control behavior specific to EDB. You can specify these properties in the connection URL or as a Properties object parameter passed to DriverManager.getConnection(). The example shows how to use a Properties object to specify additional connection properties:

String url = "jdbc:edb://localhost/edb";
Properties props = new Properties();

props.setProperty("user", "enterprisedb");
props.setProperty("password", "enterprisedb");
props.setProperty("sslfactory", "com.edb.ssl.NonValidatingFactory");
props.setProperty("ssl", "true");

Connection con = DriverManager.getConnection(url, props);
Note

By default, the combination of SSL=true and setting the connection URL parameter sslfactory=org.postgresql.ssl.NonValidatingFactory encrypts the connection but doesn't validate the SSL certificate. To enforce certificate validation, you must use a Custom SSLSocketFactory. For more details about writing a Custom SSLSocketFactory, see the the PostgreSQL JDBC driver documentation.

To specify additional connection properties in the URL, add a question mark and an ampersand-separated list of keyword-value pairs:

String url = "jdbc:edb://localhost/edb?user=enterprisedb&ssl=true";

Some of the additional connection properties are shown in the following table.

NameTypeDescription
userStringThe database user on whose behalf the connection is being made.
passwordStringThe database user’s password.
sslBooleanRequests an authenticated, encrypted SSL connection.
charSetStringThe value of charSet determines the character set used for data sent to or received from the database.
prepareThresholdIntegerThe value of prepareThreshold determines the number of PreparedStatement executions required before switching to server-side prepared statements. The default is five.
loadBalanceHostsBooleanIn default mode (disabled) hosts are connected in the given order. If enabled, hosts are chosen randomly from the set of suitable candidates.
targetServerTypeStringAllows opening connections to only servers with the required state. The allowed values are any, primary, secondary, preferSecondary, and preferSyncSecondary. The primary/secondary distinction is currently done by observing if the server allows writes. The value preferSecondary tries to connect to secondaries if any are available, otherwise allows connecting to the primary. The EDB Postgres Advanced Server JDBC Connector supports preferSyncSecondary, which permits connection to only synchronous secondaries or the primary if there are no active synchronous secondaries.
skipQuotesOnReturningBooleanWhen set to true, column names from the RETURNING clause aren't quoted. This eliminates a case-sensitive comparison of the column name. When set to false (the default setting), column names are quoted.
changeServerNameBooleanThe getServerName() call in PgConnection.java returns EnterpriseDB. If changeServerName is set to true, it returns the value as PostgreSQL. The default value is false.
forceBinaryTransferBooleanIf the value is set to true, forces the transfer of all binary types from the PostgreSQL server to the JDBC driver in their binary form. The default value is false.