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.

An IPv6 address goes in brackets, jdbc:octavius://[::1]:5432/res_publica, and is stored without them: the brackets separate the address from the port and belong to the URL, not to the host that is later matched against a certificate.

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.