Package csv.impl
Class JdbcReader
java.lang.Object
csv.impl.AbstractTableReader
csv.impl.JdbcReader
- All Implemented Interfaces:
TableReader,Iterable<Object[]>,Iterator<Object[]>
Implements a table reader to read JDBC ResultSet rows.
- Author:
- ralph
-
Constructor Summary
ConstructorsConstructorDescriptionJdbcReader(ResultSet resultSet) Default constructor.JdbcReader(Statement statement) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the reader.intReturns the number of columns the result set returns.Returns the JDBC result set of this reader.booleanhasNext()Returns true if there are more rows to be delivered.booleanReturns true if a call toclose()will also close the result set.Object[]next()Returns the next row.voidopen()Opens the reader.protected voidReads the header row.protected voidReads the next row from the result set.voidremove()Forwards to JDBC result set.voidreset()Resets the result set cursor before the first row.voidsetCloseResultSet(boolean closeResultSet) Sets whether the result set will be closed.protected voidsetResultSet(ResultSet resultSet) Sets the JDBC result set for this reader.Methods inherited from class csv.impl.AbstractTableReader
convert, convert, convertArray, convertArray, get, getColumnIndex, getColumnType, getHeaderRow, getLineCount, getMapper, getMinimumColumnCount, getRowCount, hasHeaderRow, incrementLineCount, incrementRowCount, isHeaderRowRead, iterator, notifyComment, registerCommentCallBack, setColumnType, setHasHeaderRow, setHeaderRow, setHeaderRowRead, setMapper, setMinimumColumnCount, unregisterCommentCallBackMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
JdbcReader
Default constructor.- Parameters:
resultSet- the JDBC result set to read data from
-
JdbcReader
Default constructor.- Parameters:
statement- JDBC statement ready to be executed- Throws:
SQLException- when the statement cannot be used
-
-
Method Details
-
setResultSet
Sets the JDBC result set for this reader.- Parameters:
resultSet- the resultSet to set
-
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:
closein interfaceTableReader- Overrides:
closein classAbstractTableReader- See Also:
-
open
public void open()Opens the reader.- Specified by:
openin interfaceTableReader- Overrides:
openin classAbstractTableReader- See Also:
-
reset
public void reset()Resets the result set cursor before the first row.- Specified by:
resetin interfaceTableReader- Overrides:
resetin classAbstractTableReader- See Also:
-
readHeaderRow
protected void readHeaderRow()Reads the header row.- Overrides:
readHeaderRowin classAbstractTableReader
-
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
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 toclose()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
-