Class JdbcDataSourceConnector
- All Implemented Interfaces:
DataSourceConnector,AutoCloseable
DataSourceConnector that reads connection-backed tables over JDBC.
For a relation declared as source T from conn { … } or referenced as
conn.table, this connector resolves the relation's
ConnectionTableSourceConfig (from SemanticModel.sources()) and
the matching ConnectionDeclaration (from SemanticModel.connections()),
opens a JDBC connection, runs SELECT * FROM <table>, and maps each
ResultSet row to a relix Row using the requested schema.
Rows are streamed lazily: the returned Stream pulls from the live
ResultSet and, when the stream is closed, closes the ResultSet
and Statement and releases the Connection back to a
ConnectionPool for reuse. The executor closes every source stream
(materialising operators via try-with-resources, the terminal stream in
QueryExecutor), so connections are released deterministically. A driver
fetch-size hint is set so drivers that honour it stream from a server-side
cursor rather than buffering the whole result. Credentials are taken from the
(placeholders already resolved) connection configuration.
close() closes the pool — but only when the connector created it
(the JdbcDataSourceConnector(SemanticModel) constructor); a pool passed
in is owned by the caller.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a connector with its ownConnectionPool, closed byclose().JdbcDataSourceConnector(SemanticModel model, DriverProvisioner provisioner) Creates a connector (with its own pool) that provisions a missing JDBC driver on demand viaprovisionerbefore failing.JdbcDataSourceConnector(SemanticModel model, ConnectionPool pool) Creates a connector backed by a sharedConnectionPool; the pool is owned by the caller and is not closed byclose().JdbcDataSourceConnector(SemanticModel model, ConnectionPool pool, DriverProvisioner provisioner) Creates a connector over a sharedConnectionPoolthat also provisions a missing JDBC driver on demand — the two halves of the other constructors at once. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases any resources the connector holds (e.g.Opens a stream of rows for the named relation.Runs a pushed-down native query on a named connection and streams the result.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.darkcollective.relix.processor.internal.DataSourceConnector
openQuery
-
Constructor Details
-
JdbcDataSourceConnector
Creates a connector with its ownConnectionPool, closed byclose().- Parameters:
model- the semantic model whose sources and connections describe each JDBC-backed relation; must not be null
-
JdbcDataSourceConnector
Creates a connector backed by a sharedConnectionPool; the pool is owned by the caller and is not closed byclose().- Parameters:
model- the semantic model; must not be nullpool- the shared connection pool; must not be null
-
JdbcDataSourceConnector
Creates a connector (with its own pool) that provisions a missing JDBC driver on demand viaprovisionerbefore failing.- Parameters:
model- the semantic model; must not be nullprovisioner- the driver provisioner consulted when no driver is registered for a connection URL; must not be null
-
JdbcDataSourceConnector
public JdbcDataSourceConnector(SemanticModel model, ConnectionPool pool, DriverProvisioner provisioner) Creates a connector over a sharedConnectionPoolthat also provisions a missing JDBC driver on demand — the two halves of the other constructors at once.This is the shape a long-lived host wants: the pool outlives any one query, so it is the caller's and is not closed by
close(), while a pool built over aConnectionProviderthat serves live handles is how a boundDataSourcereaches execution.- Parameters:
model- the semantic model; must not be nullpool- the shared connection pool; must not be nullprovisioner- the driver provisioner consulted when no driver is registered for a connection URL; must not be null
-
-
Method Details
-
close
public void close()Description copied from interface:DataSourceConnectorReleases any resources the connector holds (e.g. a pool of database connections). The default does nothing, so simple lambda connectors need not implement it; resource-backed connectors override it. Overrides do not throw checked exceptions, sotry-with-resources needs no extra catch.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDataSourceConnector
-
open
Description copied from interface:DataSourceConnectorOpens a stream of rows for the named relation.- Specified by:
openin interfaceDataSourceConnector- Parameters:
relationName- the canonical (lower-cased) relation nameschema- the expected schema; may be used to map source columns to the correct positions and types- Returns:
- a stream of rows; the caller is responsible for closing it
-
openQuery
Description copied from interface:DataSourceConnectorRuns a pushed-down native query on a named connection and streams the result.Columns are read positionally, in
schemaorder, so the query's result column order must matchschema. The default implementation rejects pushdown; connectors that support native-query execution override it.- Specified by:
openQueryin interfaceDataSourceConnector- Parameters:
connectionName- the canonical name of the connection to run the query onnativeQuery- the backend-native query text (SQL for JDBC, etc.)schema- the expected output schema; columns are read by position- Returns:
- a stream of rows; the caller is responsible for closing it
-