Interface ResultSetScanner<T>

Type Parameters:
T - the collected result type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ResultSetScanner<T>
Scan over rows of result sets, mapping and collecting the rows to a result type. Unlike the Row and ColumnMappers, this interface lets you control the ResultSet scrolling - the implementation should ResultSet.next() over rows it wants to consider.
See Also:
  • Method Details

    • scanResultSet

      T scanResultSet(Supplier<ResultSet> resultSetSupplier, StatementContext ctx) throws SQLException
      Scans the lazily-supplied result set into a result. The ResultSet is not produced (and typically, the statement the result came from is not executed) until resultSetSupplier.get() is called.

      Implementors that call resultSetSupplier.get() must ensure that the statement context is closed, to ensure that database resources are freed:

       try {
           ResultSet resultSet = resultSetSupplier.get()
           // generate and return result from the result set.
       }
       finally {
           ctx.close();
       }
       

      Alternatively, implementors may return some intermediate result object (e.g. ResultIterable) without calling resultSetSupplier.get(), in which case the burden of closing resources falls to whichever object ultimately does get() the result set.

      Parameters:
      resultSetSupplier - supplies a ResultSet.
      ctx - the statement context.
      Returns:
      the mapped result
      Throws:
      SQLException - if anything goes wrong