Writing a JDBC provider
jdbc-genericreads one database per connector. The database it speaks is decided by a provider: a module that owns that database's SQL dialect and its JDBC driver. PostgreSQL ships with every edition, Oracle with lumnik Pro; any other database is one more provider.
This page is for a Java developer adding a database. Using an installed provider needs no code — see JDBC → Connection.
What a provider is
- A Maven module
io.lumnik:lumnik-jdbc-<db>, classes under the packageio.lumnik.jdbc.<db>. - It depends on
lumnik-jdbc-spiand on its own driver, even when the hub already carries it. - It exposes one CDI bean implementing
JdbcDialect. The hub never imports a provider class; it collects every installed bean.
Two build details decide whether the hub sees the provider at all:
- the module builds a jandex index (
jandex-maven-plugin) — without it the hub boots with that dialect missing, and says nothing; - the hub depends on it with
runtimescope.
Providers add up: several live in one image, and each connector picks its own.
What each method owes
| Method | Contract |
|---|---|
id() |
The lowercase name used in dialect:. Unique across installed providers. |
aliases() |
Other accepted spellings (PostgreSQL: postgresql). Unique too. |
acceptsUrl(url) |
Whether this provider recognises the JDBC scheme. Used to infer a missing dialect:. |
driverClass() |
The driver the pool loads. A provider installed without its driver fails with JDBC driver 'X' of dialect 'Y' is not on the classpath. |
connectHosts(url) |
The hosts the URL connects to, as your driver reads it. The hub judges each one before a pool opens (Where the hub connects). Use the driver's own parser when it has one. A URL whose hosts you cannot tell (an alias resolved elsewhere, a parameter that picks its own socket) throws IllegalArgumentException saying why, never quoting the URL. No default. |
isolationProperties() |
The driver properties the hub sets on every connection so your driver offers nothing of the hub's own (a default client certificate, a Kerberos login). Refuse their names in connectHosts. No default. |
timeoutProperties(connect, read) |
The driver properties that bound opening a connection and logging in, always, and each read when read is present. The hub asks for a read bound on its doors (test, discovery) only. No default: the names and units are your driver's. |
quoteIdentifier(id) |
Quote one identifier. The query builder never concatenates a raw name. |
keyComparison(columns, comparison) |
The > (cursor) or <= (run ceiling) comparison over the quoted key columns, and the bind plan. No default. |
limitClause(n) |
The row limit appended after ORDER BY (LIMIT 100, FETCH FIRST 100 ROWS ONLY, …). No default. |
defaultSkipPatterns() |
Table-name globs excluded from discovery when the request gives none. |
unsupportedReason(column) |
Why this provider cannot read a column, or empty. Discovery lists the table with the column named; the guided add refuses it. Default: every column is readable. |
readColumn(rs, index) |
The value of a cell. Default getObject; override for a LOB locator or a driver-specific timestamp class, and throw to refuse a type you cannot read. |
isWallClock(metadata, index) |
Whether the column holds a date and time written with no time zone, which the hub then reads in the connection's zone, UTC without one. Default: the column's JDBC type is TIMESTAMP. Override it when your driver reports a zoned type under that same code. |
sessionInitSql() |
A statement run on every new connection of this dialect's pool — for a database whose session settings (sort order, number format) change what a query means. Default: none. |
| introspection | listTables, listViews (no default: a provider that cannot list views throws SQLException saying so, never an empty list), tableExists, listColumns, listPrimaryKey, listForeignKeys, estimateRowCount, inferWatermarkColumn. |
keyComparison and limitClause have no default so that a provider cannot compile while emitting
SQL its database rejects, or reads differently. connectHosts and timeoutProperties have none either: an inherited
answer would let your URLs past unjudged, or set properties your driver does not read. Nor does
isolationProperties: it returns the driver properties that stop your driver offering the hub's own
files, keys or tickets to a tenant's server (a client certificate it would load by default, a
Kerberos login). The hub sets them on every connection. Your connectHosts must refuse a URL that
names one of them: the driver lets the URL win. Return an empty map when your driver reads nothing
by itself.
The bind plan
keyComparison returns a KeyComparison(sql, parameterIndexes). The i-th ? of the SQL takes the
value of key column parameterIndexes[i].
| Dialect | SQL for (a, b) > cursor |
Plan |
|---|---|---|
| PostgreSQL (row value) | ("a", "b") > (?, ?) |
[0, 1] |
| a database without tuple comparison | (("a" > ?) OR ("a" = ? AND "b" > ?)) |
[0, 0, 1] |
- The SQL is one self-contained, parenthesised predicate: the builder joins it with
AND, and for a watermark ceiling withOR <watermark> IS NULL. - The builder refuses a plan that is empty for a non-empty key, or that names a column that does not exist.
How a connector picks its provider
| Manifest | Result |
|---|---|
dialect: names an installed provider, URL accepted |
that provider |
dialect: names a provider that is not installed |
refused: JDBC dialect 'X' is not installed. Available: … |
dialect: set, URL not accepted by it |
refused, naming the dialect and the URL scheme |
dialect: absent, exactly one provider accepts the URL |
that provider |
dialect: absent, none accepts it |
refused, listing the installed providers |
dialect: absent, several accept it |
refused as ambiguous |
- Names are compared trimmed and lowercased.
- Two providers claiming the same id or alias stop the hub at startup, naming both.
- A connection pool is kept per URL, user, password, tenant, driver and dialect: two providers that accept the same URL never share one. A pool nobody asked for in ten minutes, and that lends no connection, is closed.
Build it in, and check it
- Add your module to the hub as a
runtimedependency, in a Maven profile, like the Oracle one inlumnik-hub/pom.xml. - Rebuild the hub image with that profile.
-
Point
lmat a database of your kind:lm source jdbc test --url jdbc:<db>://host:port/base --user ro_userThe answer names your provider on its
Dialect :line. A hub built without it refuses the URL, listing the providers it has.