public interface CloseableIterator<T> extends Iterator<T>, AutoCloseable
NOTE: You must call AutoCloseable.close()
method when you are done otherwise the underlying SQL
statement and connection may be kept open.
Modifier and Type | Method and Description |
---|---|
void |
closeQuietly()
Close any underlying SQL statements but swallow any SQLExceptions.
|
T |
current()
Return the current result object that we have accessed or null if none.
|
T |
first()
Move to the first result and return it or null if none.
|
DatabaseResults |
getRawResults()
Return the underlying database results object if any.
|
T |
moveAbsolute(int position)
Move to an absolute position in the list and return that result or null if none.
|
T |
moveRelative(int offset)
Move a relative position in the list and return that result or null if none.
|
void |
moveToNext()
Move to the next item in the iterator without calling
Iterator.next() . |
T |
nextThrow()
Returns the
Iterator.next() object in the table or null if none. |
T |
previous()
Moves to the previous result and return it or null if none.
|
forEachRemaining, hasNext, next, remove
close
void closeQuietly()
DatabaseResults getRawResults()
void moveToNext()
Iterator.next()
.T first() throws SQLException
SQLException
T previous() throws SQLException
SQLException
T current() throws SQLException
SQLException
T nextThrow() throws SQLException
Iterator.next()
object in the table or null if none.SQLException
- Throws a SQLException on error since Iterator.next()
cannot throw because it is part of the
Iterator
definition. It will not throw if there is no next.T moveRelative(int offset) throws SQLException
Iterator.next()
.
moveRelative(-1) is the same as previous()
result. This may not work with the default iterator depending
on your database.offset
- Number of rows to move. Positive moves forward in the results. Negative moves backwards.SQLException
T moveAbsolute(int position) throws SQLException
position
- Row number in the result list to move to.SQLException
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.