Class JdbcLookup
java.lang.Object
com.northconcepts.datapipeline.transform.lookup.Lookup
com.northconcepts.datapipeline.transform.lookup.JdbcLookup
A
Lookup that runs a SQL query for each lookup, binding the key values to its parameters in order.-
Constructor Summary
ConstructorsConstructorDescriptionJdbcLookup(JdbcConnectionFactory factory, String query) Creates a new instance with theautoCloseConnectionproperty set totrue.JdbcLookup(JdbcConnectionFactory factory, String query, int... jdbcTypes) Creates a new instance with theautoCloseConnectionproperty set totrue.JdbcLookup(Connection connection, String query) Creates a new instance with theautoCloseConnectionproperty set tofalse.JdbcLookup(Connection connection, String query, int... jdbcTypes) Creates a new instance with theautoCloseConnectionproperty set tofalse. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclose()Called when theLookupTransformerusing this lookup is closed; override to release resources.Returns the records that match the supplied composite lookup key.booleanIndicates if the database connection in this lookup should be closed when the lookup is closed by theLookupTransformervia aTransformingReaderorTransformingWriter.setAutoCloseConnection(boolean autoCloseConnection) Indicates if the database connection in this lookup should be closed when the lookup is closed by theLookupTransformervia aTransformingReaderorTransformingWriter.toString()
-
Constructor Details
-
JdbcLookup
Creates a new instance with theautoCloseConnectionproperty set tofalse.- Parameters:
connection-query-jdbcTypes- jdbcTypes tells the JDBC driver the SQL type of data to expect for any query params that are specified as question marks and sent with statement.setObject(...); or statement.setNull(...), otherwise, the driver will have to guess. For example java.util.Date can be DATE, TIME, TIMESTAMP, DATETIME, etc., on the SQL side.
-
JdbcLookup
Creates a new instance with theautoCloseConnectionproperty set tofalse.- Parameters:
connection-query-
-
JdbcLookup
Creates a new instance with theautoCloseConnectionproperty set totrue.- Parameters:
factory-query-jdbcTypes- jdbcTypes tells the JDBC driver the SQL type of data to expect for any query params that are specified as question marks and sent with statement.setObject(...); or statement.setNull(...), otherwise, the driver will have to guess. For example java.util.Date can be DATE, TIME, TIMESTAMP, DATETIME, etc., on the SQL side.
-
JdbcLookup
Creates a new instance with theautoCloseConnectionproperty set totrue.- Parameters:
factory-query-
-
-
Method Details
-
get
Description copied from class:LookupReturns the records that match the supplied composite lookup key.Contract for subclasses (see also
docs/authoring/Lookup.md):- Called once per source record by
LookupTransformer; keep it fast. - Return an empty
RecordListwhen no match is found.nullis also tolerated byLookupTransformerfor backward compatibility, but new code should prefer an empty list for clearer semantics. - Do not mutate the supplied
keys; they are owned by the caller.
- Called once per source record by
-
isAutoCloseConnection
public boolean isAutoCloseConnection()Indicates if the database connection in this lookup should be closed when the lookup is closed by theLookupTransformervia aTransformingReaderorTransformingWriter. The default isfalseif this instance was constructed with aConnectionortrueif constructed with aJdbcConnectionFactory. -
setAutoCloseConnection
Indicates if the database connection in this lookup should be closed when the lookup is closed by theLookupTransformervia aTransformingReaderorTransformingWriter. The default isfalseif this instance was constructed with aConnectionortrueif constructed with aJdbcConnectionFactory. -
toString
-
close
protected void close()Description copied from class:LookupCalled when theLookupTransformerusing this lookup is closed; override to release resources.
-