Class JdbcReader


public class JdbcReader extends DataReader
Obtains records from a database query.
  • Field Details

    • currentRecord

      protected Record currentRecord
  • Constructor Details

    • JdbcReader

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

      public JdbcReader(Connection connection, String queryString, Object... parameters)
      Creates a new instance with the autoCloseConnection property set to false.
      Parameters:
      connection -
      queryString -
      parameters -
    • JdbcReader

      public JdbcReader(Connection connection, String queryString, Object[] parameters, int[] parameterSqlTypes)
      Creates a new instance with the autoCloseConnection property set to false.
      Parameters:
      connection -
      queryString -
      parameters -
      parameterSqlTypes -
    • JdbcReader

      public JdbcReader(JdbcConnectionFactory factory, String queryString) throws DataException
      Creates a new instance with the autoCloseConnection property set to true.
      Parameters:
      factory -
      queryString -
      Throws:
      DataException
    • JdbcReader

      public JdbcReader(JdbcConnectionFactory factory, String queryString, Object... parameters)
      Creates a new instance with the autoCloseConnection property set to true.
      Parameters:
      factory -
      queryString -
      parameters -
    • JdbcReader

      public JdbcReader(JdbcConnectionFactory factory, String queryString, Object[] parameters, int[] parameterSqlTypes)
      Creates a new instance with the autoCloseConnection property set to true.
      Parameters:
      factory -
      queryString -
      parameters -
      parameterSqlTypes -
  • Method Details

    • getAutoCloseConnection

      public boolean getAutoCloseConnection()
      Indicates if the database connection in this endpoint should be closed when the endpoint is closed. The default is false if this instance was constructed with a Connection or true if constructed with a JdbcConnectionFactory.
    • setAutoCloseConnection

      public JdbcReader setAutoCloseConnection(boolean closeConnection)
      Indicates if the database connection in this endpoint should be closed when the endpoint is closed. The default is false if this instance was constructed with a Connection or true if constructed with a JdbcConnectionFactory.
    • getValueReader

      public JdbcValueReader getValueReader()
      Returns the strategy that maps column types and reads values (defaults to JdbcValueReader.OPINIONATED).
    • setValueReader

      public JdbcReader setValueReader(JdbcValueReader valueReader)
      Sets the strategy that maps column types and reads values; null restores JdbcValueReader.OPINIONATED.
    • getUseColumnLabel

      public boolean getUseColumnLabel()
      Indicates if column labels (or aliases) are used for field names instead of the underlying, real column names (defaults to false).
    • getFetchSize

      public Integer getFetchSize()
      The fetch size to set on the Statement using Statement.setFetchSize(int) or null if the connection's default should be used (default null).
    • setFetchSize

      public JdbcReader setFetchSize(Integer fetchSize)
      The fetch size to set on the Statement using Statement.setFetchSize(int) or null if the connection's default should be used (default null).
    • setUseColumnLabel

      public JdbcReader setUseColumnLabel(boolean useColumnLabel)
      When set to true, column labels (or aliases) will be used for field names instead of the underlying, real column names. Defaults to false.
    • setSaveLineage

      public JdbcReader setSaveLineage(boolean saveLineage)
      Description copied from class: DataReader
      Indicates if record and field lineage is captured for each record read (default is false); enabling it throws if DataReader.isLineageSupported() is false or the product edition does not include lineage.
      Overrides:
      setSaveLineage in class DataReader
    • isStrictTypeMapping

      public boolean isStrictTypeMapping()
      Indicates if database types should be mapped to java type based only on java.sql.Types as defined by Sun/Oracle (defaults to false). Otherwise, the column display size and scale will be considered for numeric types.
      See Also:
    • setStrictTypeMapping

      public JdbcReader setStrictTypeMapping(boolean strictTypeMapping)
      Indicates if database types should be mapped to java type based only on java.sql.Types as defined by Sun/Oracle (defaults to false). Otherwise, the column display size and scale will be considered for numeric types.
      See Also:
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class DataReader
    • read

      public Record read() throws DataException
      Description copied from class: DataReader
      Reads the next record from this DataReader and increases the record-count by 1. This method will first read any pushed (DataReader.push(Record)) records before reading from the underlying source.

      If no record is available, null will be returned. This method blocks until a record is available, the end of the stream is reached, or an exception is thrown.

      Any exception raised while reading will be converted to a DataException using DataObject.exception(Throwable).

      Subclasses generally do not need to override this method, instead they should implement DataReader.readImpl().

      Overrides:
      read in class DataReader
      Throws:
      DataException
      See Also:
    • readImpl

      protected Record readImpl() throws Throwable
      Description copied from class: DataReader
      Overridden by subclasses to read the next record from this DataReader. The default implementation of DataReader.read() now insures that this method will not be called again after it returns a null.

      If no record is available, null will be returned.

      Contract for subclasses (see also docs/authoring/DataReader.md):

      Specified by:
      readImpl in class DataReader
      Throws:
      Throwable
    • isLineageSupported

      public boolean isLineageSupported()
      Description copied from class: DataReader
      Indicates if this reader can capture record and field lineage (false unless overridden by a reader that supports it).
      Overrides:
      isLineageSupported in class DataReader
    • addLineage

      protected Record addLineage(Record record)
      Description copied from class: DataReader
      Called by DataReader.read() for each record from DataReader.readImpl() while lineage is saved; the default copies recordLineage into every field along with its original index and name. Overrides set their source details on recordLineage first and end with super.addLineage(record).
      Overrides:
      addLineage in class DataReader
    • open

      public void open()
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class DataEndpoint
    • close

      public void close()
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class DataEndpoint