Package org.jdbi.v3.core.result
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.
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.-
Method Summary
Modifier and TypeMethodDescriptionscanResultSet
(Supplier<ResultSet> resultSetSupplier, StatementContext ctx) Scans the lazily-supplied result set into a result.
-
Method Details
-
scanResultSet
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) untilresultSetSupplier.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 callingresultSetSupplier.get()
, in which case the burden of closing resources falls to whichever object ultimately doesget()
the result set.- Parameters:
resultSetSupplier
- supplies a ResultSet.ctx
- the statement context.- Returns:
- the mapped result
- Throws:
SQLException
- if anything goes wrong
-