Interface ResultSet<T>

Type Parameters:
T - A type of the objects contained by this result set (when row set is present). This will be either SqlRow if no explicit mapper is provided or a particular type defined by supplied mapper.
All Superinterfaces:
AutoCloseable, Cursor<T>, Iterator<T>

public interface ResultSet<T> extends Cursor<T>
Provides methods to access SQL query results represented by a collection of SqlRow.

All rows in the result set have the same structure described in ResultSetMetadata. ResultSet must be closed after usage to free resources.

The class and its methods are not thread-safe. If more than one thread use the result set object, use external synchronization on iterator methods.

Note: Only one of following is possible: hasRowSet() returns true, or wasApplied() returns true, or affectedRows() return zero or higher value.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or 0 if the statement returns nothing (such as "ALTER TABLE", etc.), or -1 if not applicable.
    void
    Invalidates result set and cleans up remote resources.
    boolean
    Indicates whether the query result is a collection of rows.
    Returns metadata for the results if the result contains rows (if hasRowSet() returns true).
    boolean
    Indicates whether the query that had produced the result was a conditional query.

    Methods inherited from interface java.util.Iterator

    forEachRemaining, hasNext, next, remove
  • Method Details

    • metadata

      @Nullable @Nullable ResultSetMetadata metadata()
      Returns metadata for the results if the result contains rows (if hasRowSet() returns true).
      Returns:
      ResultSet metadata or null if not applicable.
    • hasRowSet

      boolean hasRowSet()
      Indicates whether the query result is a collection of rows.

      Note: If the method returns false, calling Iterator.hasNext(), Iterator.next() will fail, and either affectedRows() returns the number of the affected rows or wasApplied() returns true.

      Returns:
      True if the query returns rows, false otherwise.
    • affectedRows

      long affectedRows()
      Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or 0 if the statement returns nothing (such as "ALTER TABLE", etc.), or -1 if not applicable.

      Note: If the method returns -1, either hasRowSet() or wasApplied() returns true.

      Returns:
      Number of rows affected by the query, or 0 if statement return nothing, or -1 if not applicable.
    • wasApplied

      boolean wasApplied()
      Indicates whether the query that had produced the result was a conditional query. E.g., for query "Create table if not exists", the method returns true if the operation was successful, and false if the operation was ignored because the table already existed.

      Note: If the method returns false, either affectedRows() returns the number the affected rows or hasRowSet() returns true.

      Returns:
      True if the query is conditional, false otherwise.
    • close

      void close()
      Invalidates result set and cleans up remote resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Cursor<T>