Class ResultSetIterator
java.lang.Object
org.apache.commons.dbutils.ResultSetIterator
Wraps a ResultSet in an Iterator<Object[]>. This is useful
when you want to present a non-database application layer with domain
neutral data.
This implementation requires the ResultSet.isLast() method
to be implemented.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RowProcessorThe processor to use when converting a row into an Object[].private final ResultSetThe wrappedResultSet. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for ResultSetIterator.ResultSetIterator(ResultSet rs, RowProcessor convert) Constructor for ResultSetIterator. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()Returns true if there are more rows in the ResultSet.Generates anIterable, suitable for use in for-each loops.Object[]next()Returns the next row as anObject[].voidremove()Deletes the current row from theResultSet.protected voidRethrow the SQLException as a RuntimeException.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining
-
Field Details
-
rs
The wrappedResultSet. -
convert
The processor to use when converting a row into an Object[].
-
-
Constructor Details
-
ResultSetIterator
Constructor for ResultSetIterator.- Parameters:
rs- Wrap thisResultSetin anIterator.
-
ResultSetIterator
Constructor for ResultSetIterator.- Parameters:
rs- Wrap thisResultSetin anIterator.convert- The processor to use when converting a row into anObject[]. Defaults to aBasicRowProcessor.
-
-
Method Details
-
hasNext
public boolean hasNext()Returns true if there are more rows in the ResultSet.- Specified by:
hasNextin interfaceIterator<Object[]>- Returns:
- boolean
trueif there are more rows - Throws:
RuntimeException- if an SQLException occurs.
-
next
Returns the next row as anObject[].- Specified by:
nextin interfaceIterator<Object[]>- Returns:
- An
Object[]with the same number of elements as columns in theResultSet. - Throws:
RuntimeException- if an SQLException occurs.- See Also:
-
remove
public void remove()Deletes the current row from theResultSet.- Specified by:
removein interfaceIterator<Object[]>- Throws:
RuntimeException- if an SQLException occurs.- See Also:
-
rethrow
Rethrow the SQLException as a RuntimeException. This implementation creates a new RuntimeException with the SQLException's error message.- Parameters:
e- SQLException to rethrow- Since:
- DbUtils 1.1
-
iterable
-