Copyright © 2008-2011 Ralph Schuster. All Rights Reserved.

csv.impl
Class JdbcReader

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

public class JdbcReader
extends AbstractTableReader

Implements a table reader to read JDBC ResultSet rows.

Author:
ralph

Constructor Summary
JdbcReader(java.sql.ResultSet resultSet)
          Default constructor.
JdbcReader(java.sql.Statement statement)
          Default constructor.
 
Method Summary
 void close()
          Closes the reader.
 int getColumnCount()
          Returns the number of columns the result set returns.
 java.sql.ResultSet getResultSet()
          Returns the JDBC result set of this reader.
 boolean hasNext()
          Returns true if there are more rows to be delivered.
 boolean isCloseResultSet()
          Returns true if a call to close() will also close the result set.
 java.lang.Object[] next()
          Returns the next row.
 void open()
          Opens the reader.
protected  void readHeaderRow()
          Reads the header row.
protected  void readNextRow()
          Reads the next row from the result set.
 void remove()
          Forwards to JDBC result set.
 void reset()
          Resets the result set cursor before the first row.
 void setCloseResultSet(boolean closeResultSet)
          Sets whether the result set will be closed.
protected  void setResultSet(java.sql.ResultSet resultSet)
          Sets the JDBC result set for this reader.
 
Methods inherited from class csv.impl.AbstractTableReader
addCommentCallBack, convert, convert, convertArray, convertArray, get, getColumnIndex, getColumnType, getHeaderRow, getLineCount, getMinimumColumnCount, getRowCount, getTypeConversionHandler, hasHeaderRow, incrementLineCount, incrementRowCount, isHeaderRowRead, notifyComment, registerCommentCallBack, registerTypeConversionHandler, removeCommentCallBack, setColumnType, setHasHeaderRow, setHeaderRow, setHeaderRowRead, setMinimumColumnCount, unregisterCommentCallBack, unregisterTypeConversionHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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
Method Detail

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

Copyright © 2008-2011 Ralph Schuster. All Rights Reserved.

Copyright © 2008-2011 Ralph Schuster. All Rights Reserved.