createConnection

fun createConnection(url: String, info: Properties? = null): Connection

Creates a new database connection using the provided JDBC URL and optional properties.

Return

A newly established Connection (specifically, an OctaviusConnection).

Parameters

url

The JDBC URL (e.g., jdbc:octavius://localhost:5432/db).

info

Additional connection properties.

Throws

if the connection cannot be established or the server version is unsupported.


Creates a new database connection using the pre-parsed OctaviusProperties.

Every server listed is tried in turn - in the order given, or shuffled under load_balance_hosts=random - and so is every address its name resolves to, until one becomes a connection. What moves the search on follows libpq:

  • nothing answering at an address, or not within loginTimeout, moves on to the next address;

  • a server that takes no connections now (57P03), is not the kind target_session_attrs asks for, or is not of the cluster the type catalog belongs to moves on to the next server;

  • anything else - a rejected password, a failed TLS handshake, a database that does not exist - would be the same on every server, so it ends the search and is thrown as it is, with what was tried before it suppressed.

prefer-standby searches twice: for a standby, and where the list has none, for any server.

Return

A newly established Connection.

Parameters

properties

The parsed configuration properties.

Throws

if the connection cannot be established or the server version is unsupported. Where several addresses were tried and none became a connection, CONNECTION_ERROR listing each, unless one of them ended the search.