Package org.jdbi.v3.core.statement
Interface StatementBuilder
- All Known Implementing Classes:
DefaultStatementBuilder
public interface StatementBuilder
Used to convert translated SQL into a prepared statement. The default implementation
created by
DefaultStatementBuilder.FACTORY
creates a new statement on every call.
A StatementBuilder is always associated with exactly one Handle instance- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(Connection conn) Called when the handle this StatementBuilder is attached to is closed.void
close
(Connection conn, String sql, Statement stmt) Called to close an individual prepared statement created from this builder.create
(Connection conn, String sql, StatementContext ctx) Called each time a prepared statement needs to be created.create
(Connection conn, StatementContext ctx) Called each time a statement needs to be created.createCall
(Connection conn, String sql, StatementContext ctx) Called each time a Callable statement needs to be created.
-
Method Details
-
create
Called 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:
SQLException
- if anything goes wrong getting the statement
-
create
Called 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:
SQLException
- if anything goes wrong preparing the statement
-
createCall
Called 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 this is building for- Returns:
- a CallableStatement for the given arguments
- Throws:
SQLException
- if anything goes wrong preparing the statement
-
close
Called to close an individual prepared statement created from this builder.- Parameters:
conn
- the connection to closesql
- the translated SQL which was preparedstmt
- the statement- Throws:
SQLException
- if anything goes wrong closing the statement
-
close
Called when the handle this StatementBuilder is attached to is closed.- Parameters:
conn
- the connection to close.
-