T
- the result type@FunctionalInterface public interface PreparedStatementFunction<T>
Database
class but it's also useful for custom purposes.
Note: the passed-in PreparedStatement may have been created by Database
or by a custom PreparedStatementCreator
implementation.
However, the latter is hardly ever necessary, as most custom callback actions will perform updates
in which case a standard PreparedStatement is fine. Custom actions will
always set parameter values themselves, so that PreparedStatementCreator
capability is not needed either.
Implementations don't need to worry about handling exceptions:
they will be handled internally by DataOperations
implementations.
If the handling is done in async context then implementations should make the details available in some way.
AsyncDataOperations
may place these details inside a never null CompletableFuture object.
Modifier and Type | Method and Description |
---|---|
T |
apply(@NotNull PreparedStatement ps)
|
@Nullable T apply(@NotNull @NotNull PreparedStatement ps) throws SQLException
Database.execute(String, PreparedStatementFunction)
or Database.execute(PreparedStatementCreator, PreparedStatementFunction)
.
ATTENTION: any ResultSet should be closed within this callback implementation. This method doesn't imply that the ResultSet (as other resources) will be closed. Still, this method should grant (as shown in Database various implementations) that the statement will be closed at the end of the operations.
ps
- an active PreparedStatementSQLException
- if thrown by a Database's method (no need to catch).Copyright © 2021. All rights reserved.