Package csv.impl

Class JdbcReader

java.lang.Object
csv.impl.AbstractTableReader
csv.impl.JdbcReader
All Implemented Interfaces:
TableReader, java.lang.Iterable<java.lang.Object[]>, java.util.Iterator<java.lang.Object[]>

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

    • JdbcReader

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

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

    • setResultSet

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

      public java.sql.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:
      TableReader.close()
    • open

      public void open()
      Opens the reader.
      Specified by:
      open in interface TableReader
      Overrides:
      open in class AbstractTableReader
      See Also:
      TableReader.open()
    • 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:
      TableReader.reset()
    • 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:
      Iterator.hasNext()
    • next

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

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

      public void remove()
      Forwards to JDBC result set.
      See Also:
      Iterator.remove()
    • 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