parse

fun parse(url: String, info: Properties? = null): OctaviusProperties

Parses a JDBC URL, optionally overlaid on a Properties set.

The expected form is jdbc:octavius://host:port/database?key=value&…, with the host, port, database and query string all optional. A URL that does not start with that prefix is not an error: nothing is parsed out of it and only info takes effect.

The address is read the way serverName reads one - see ServerAddress.entries - so an IPv6 address with a port goes in brackets, jdbc:octavius://[::1]:5432/res_publica, and a single one is stored without them: they separate the address from the port, and are not part of the host a certificate is matched against.

Several servers are separated by commas, each with a port of its own or none - jdbc:octavius://db1:5432,db2,[::1]:5433/res_publica. A single server's port goes into portNumber; several keep theirs beside them in serverName, where portNumber is the port of those stating none.

Later wins, and silence is not a value. info is applied first and the URL over it, so the URL overrides it - but only where the URL actually states something. A URL that omits the host, the port or the database leaves whatever info supplied for it in place rather than replacing it with a default. Within the URL the same rule applies left to right, so a query-string host or port parameter beats the authority that precedes it.

Nothing here fills in defaults for an unstated host, port or database: they stay null and are resolved to localhost, 5432 and postgres when the connection is opened.

Keys and values are URL-decoded, and only the first = in a parameter separates them, so a value containing more of them - a password, an options=-c search_path=curia string - arrives intact.

Values are parsed here rather than at connect time, so a URL carrying one that will not parse is refused by this call - see setProperty, which every parameter goes through.

Return

The parsed properties.

Parameters

url

The JDBC URL.

info

Additional properties, applied beneath the URL.

Throws

INVALID_ARGUMENT if a recognized property is given a value that does not parse as its type.