- Type Parameters:
T- the type to fetch from the result set
- All Superinterfaces:
AutoCloseable,Iterable<T>
Iterates through a ResultSet fetching instances of T.
Use try with resources or remember to call
close() in order to close underlying resources.-
Method Summary
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
hasNext
Returns true if a row is available in the underlying result set.- Returns:
- true if a row is available in the underlying result set
- Throws:
SQLException- in case of an exception
-
next
- Returns:
- an instance of T fetched from the result set
- Throws:
SQLException- in case of an exceptionNoSuchElementException- in case no more rows are available
-
close
void close()Closes the underlying result set and other resources held by this iterator- Specified by:
closein interfaceAutoCloseable
-
iterator
Wraps thisResultIteratorin aIterator. Any SQLExceptions that occur are rethrown as RuntimeExceptions.- Specified by:
iteratorin interfaceIterable<T>- Returns:
- a
Iteratorinstance based on thisResultIterator
-