Interface ResultIterator<T>

Type Parameters:
T - the type to fetch from the result set
All Superinterfaces:
AutoCloseable, Iterable<T>

public interface ResultIterator<T> extends 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

    Modifier and Type
    Method
    Description
    void
    Closes the underlying result set and other resources held by this iterator
    boolean
    Returns true if a row is available in the underlying result set.
    default Iterator<T>
    Wraps this ResultIterator in a Iterator.
     

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • hasNext

      boolean hasNext() throws SQLException
      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

      T next() throws SQLException
      Returns:
      an instance of T fetched from the result set
      Throws:
      SQLException - in case of an exception
      NoSuchElementException - in case no more rows are available
    • close

      void close()
      Closes the underlying result set and other resources held by this iterator
      Specified by:
      close in interface AutoCloseable
    • iterator

      default Iterator<T> iterator()
      Wraps this ResultIterator in a Iterator. Any SQLExceptions that occur are rethrown as RuntimeExceptions.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      a Iterator instance based on this ResultIterator