Package org.jdbi.v3.core.statement
Interface StatementBuilder
-
- All Known Implementing Classes:
DefaultStatementBuilder
public interface StatementBuilderUsed to convert translated SQL into a prepared statement. The default implementation created byDefaultStatementBuilder.FACTORYcreates a new statement on every call. A StatementBuilder is always associated with exactly one Handle instance- See Also:
StatementBuilderFactory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose(java.sql.Connection conn)Is called when the Handle, to which this StatementBuilder is attached to, is closed.voidclose(java.sql.Connection conn, java.lang.String sql, java.sql.Statement stmt)Called to close an individual statement created from this builder.java.sql.PreparedStatementcreate(java.sql.Connection conn, java.lang.String sql, StatementContext ctx)Called each time a prepared statement needs to be created.java.sql.Statementcreate(java.sql.Connection conn, StatementContext ctx)Called each time a statement needs to be created.java.sql.CallableStatementcreateCall(java.sql.Connection conn, java.lang.String sql, StatementContext ctx)Called each time a Callable statement needs to be created.
-
-
-
Method Detail
-
create
java.sql.Statement create(java.sql.Connection conn, StatementContext ctx) throws java.sql.SQLExceptionCalled each time a statement needs to be created.- Parameters:
conn- the JDBC Connection the statement is being created forctx- Statement context associated with the SqlStatement this is building for- Returns:
- a Statement
- Throws:
java.sql.SQLException- if anything goes wrong getting the statement
-
create
java.sql.PreparedStatement create(java.sql.Connection conn, java.lang.String sql, StatementContext ctx) throws java.sql.SQLExceptionCalled each time a prepared statement needs to be created.- Parameters:
conn- the JDBC Connection the statement is being created forsql- the translated SQL which should be preparedctx- Statement context associated with the SqlStatement this is building for- Returns:
- a PreparedStatement for the given arguments
- Throws:
java.sql.SQLException- if anything goes wrong preparing the statement
-
createCall
java.sql.CallableStatement createCall(java.sql.Connection conn, java.lang.String sql, StatementContext ctx) throws java.sql.SQLExceptionCalled each time a Callable statement needs to be created.- Parameters:
conn- the JDBC Connection the statement is being created forsql- the translated SQL which should be preparedctx- Statement context associated with the SqlStatement- Returns:
- a CallableStatement for the given arguments
- Throws:
java.sql.SQLException- if anything goes wrong preparing the statement
-
close
void close(java.sql.Connection conn, java.lang.String sql, java.sql.Statement stmt) throws java.sql.SQLExceptionCalled to close an individual statement created from this builder.- Parameters:
conn- the JDBC Connection that this statement was created for.sql- the translated SQL which was prepared.stmt- the statement.- Throws:
java.sql.SQLException- if anything goes wrong closing the statement.
-
close
default void close(java.sql.Connection conn)
Is called when the Handle, to which this StatementBuilder is attached to, is closed.- Parameters:
conn- The connection which can be used to release resources. The Connection is managed by the Handle and must not be closed by the StatementBuilder.
-
-