Package csv.impl

Class JdbcReader

All Implemented Interfaces:
TableReader, Iterable<Object[]>, Iterator<Object[]>

public class JdbcReader extends AbstractTableReader
Implements a table reader to read JDBC ResultSet rows.
Author:
ralph
  • Constructor Details

    • JdbcReader

      public JdbcReader(ResultSet resultSet)
      Default constructor.
      Parameters:
      resultSet - the JDBC result set to read data from
    • JdbcReader

      public JdbcReader(Statement statement) throws SQLException
      Default constructor.
      Parameters:
      statement - JDBC statement ready to be executed
      Throws:
      SQLException - when the statement cannot be used
  • Method Details

    • setResultSet

      protected void setResultSet(ResultSet resultSet)
      Sets the JDBC result set for this reader.
      Parameters:
      resultSet - the resultSet to set
    • getResultSet

      public ResultSet getResultSet()
      Returns the JDBC result set of this reader.
      Returns:
      the resultSet
    • close

      public void close()
      Closes the reader. If the result set was created within this class then it will be closed, too.
      Specified by:
      close in interface TableReader
      Overrides:
      close in class AbstractTableReader
      See Also:
    • open

      public void open()
      Opens the reader.
      Specified by:
      open in interface TableReader
      Overrides:
      open in class AbstractTableReader
      See Also:
    • reset

      public void reset()
      Resets the result set cursor before the first row.
      Specified by:
      reset in interface TableReader
      Overrides:
      reset in class AbstractTableReader
      See Also:
    • readHeaderRow

      protected void readHeaderRow()
      Reads the header row.
      Overrides:
      readHeaderRow in class AbstractTableReader
    • getColumnCount

      public int getColumnCount()
      Returns the number of columns the result set returns.
      Returns:
      number of columns
    • hasNext

      public boolean hasNext()
      Returns true if there are more rows to be delivered.
      See Also:
    • next

      public Object[] next()
      Returns the next row.
      See Also:
    • readNextRow

      protected void readNextRow()
      Reads the next row from the result set.
    • remove

      public void remove()
      Forwards to JDBC result set.
      See Also:
    • isCloseResultSet

      public boolean isCloseResultSet()
      Returns true if a call to close() will also close the result set.
      Returns:
      the closeResultSet
    • setCloseResultSet

      public void setCloseResultSet(boolean closeResultSet)
      Sets whether the result set will be closed.
      Parameters:
      closeResultSet - the closeResultSet to set