R - Result type@FunctionalInterface public interface ResultProducer<R>
PreparedStatement.| Modifier and Type | Method and Description |
|---|---|
R |
produce(Supplier<PreparedStatement> statementSupplier,
StatementContext ctx)
Produces a statement result from a lazily supplied
PreparedStatement. |
R produce(Supplier<PreparedStatement> statementSupplier, StatementContext ctx) throws SQLException
PreparedStatement. The statement is not executed until
statementSupplier.get() is invoked.
Implementors that call statementSupplier.get() must ensure that the statement context is closed before
returning, to ensure that database resources are freed:
try {
PreparedStatement statement = statementSupplier.get()
// generate and return result from the statement
}
finally {
ctx.close();
}
Alternatively, implementors may return some intermediate result object (e.g. ResultBearing or
ResultIterable) without calling statementSupplier.get(), in which case the burden of closing
resources falls to whichever object ultimately does get() the statement.
statementSupplier - supplies a PreparedStatement, post-execution.ctx - the statement contextSQLException - if an error occurs while producing the result.Copyright © 2019. All rights reserved.