java.lang.Object
com.northconcepts.datapipeline.transform.lookup.Lookup
com.northconcepts.datapipeline.transform.lookup.JdbcLookup

public class JdbcLookup extends Lookup
A Lookup that runs a SQL query for each lookup, binding the key values to its parameters in order.
  • Constructor Details

    • JdbcLookup

      public JdbcLookup(Connection connection, String query, int... jdbcTypes)
      Creates a new instance with the autoCloseConnection property set to false.
      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

      public JdbcLookup(Connection connection, String query)
      Creates a new instance with the autoCloseConnection property set to false.
      Parameters:
      connection -
      query -
    • JdbcLookup

      public JdbcLookup(JdbcConnectionFactory factory, String query, int... jdbcTypes)
      Creates a new instance with the autoCloseConnection property set to true.
      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

      public JdbcLookup(JdbcConnectionFactory factory, String query)
      Creates a new instance with the autoCloseConnection property set to true.
      Parameters:
      factory -
      query -
  • Method Details

    • get

      public RecordList get(Object... args)
      Description copied from class: Lookup
      Returns 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 RecordList when no match is found. null is also tolerated by LookupTransformer for 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.
      Specified by:
      get in class Lookup
    • isAutoCloseConnection

      public boolean isAutoCloseConnection()
      Indicates if the database connection in this lookup should be closed when the lookup is closed by the LookupTransformer via a TransformingReader or TransformingWriter. The default is false if this instance was constructed with a Connection or true if constructed with a JdbcConnectionFactory.
    • setAutoCloseConnection

      public JdbcLookup setAutoCloseConnection(boolean autoCloseConnection)
      Indicates if the database connection in this lookup should be closed when the lookup is closed by the LookupTransformer via a TransformingReader or TransformingWriter. The default is false if this instance was constructed with a Connection or true if constructed with a JdbcConnectionFactory.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • close

      protected void close()
      Description copied from class: Lookup
      Called when the LookupTransformer using this lookup is closed; override to release resources.
      Overrides:
      close in class Lookup