Module org.jooq
Package org.jooq

Interface Cursor<R extends Record>

Type Parameters:
R - The cursor's record type
All Superinterfaces:
AutoCloseable, Fields, Formattable, Iterable<R>

public interface Cursor<R extends Record> extends Fields, Iterable<R>, Formattable, AutoCloseable
Cursors allow for lazy, sequential access to an underlying JDBC ResultSet. Unlike Result, data can only be accessed sequentially, using an Iterator, or the cursor's hasNext() and fetch() methods.

Client code must close this Cursor in order to close the underlying PreparedStatement and ResultSet

The cursor can be consumed in two ways:

  • Record by record: Such methods can be recognised by the term "Next" in the method name, e.g. fetchNext(int).
  • Completely in one go: Such methods do not have the term "Next" in their method names, e.g. fetch().

Note: Unlike usual implementations of Iterable, a Cursor can only provide one Iterator!

Lukas Eder