Interface SqlExecutor
- All Known Implementing Classes:
DefaultSqlExecutor
public interface SqlExecutor
Classes responsible for executing the SQL implement this interface Support for custom SQL Executors.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant to let us know to include all records.static final intConstant to let us know not to skip anything. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBatch(StatementScope statementScope, Connection conn, String sql, Object[] parameters) Adds a statement to a batch.voidcleanup(SessionScope sessionScope) Clean up any batches on the session.intexecuteBatch(SessionScope sessionScope) Execute a batch of statements.executeBatchDetailed(SessionScope sessionScope) Execute a batch of statements.voidexecuteQuery(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) Long form of the method to execute a query.voidexecuteQueryProcedure(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) Execute a stored procedure.intexecuteUpdate(StatementScope statementScope, Connection conn, String sql, Object[] parameters) Execute an update.intexecuteUpdateProcedure(StatementScope statementScope, Connection conn, String sql, Object[] parameters) Execute a stored procedure that updates data.voidinit(SqlMapConfiguration config, Properties globalProps) Initializing SQL Executor by passing configuration and global properties.
-
Field Details
-
NO_SKIPPED_RESULTS
static final int NO_SKIPPED_RESULTSConstant to let us know not to skip anything.- See Also:
-
NO_MAXIMUM_RESULTS
static final int NO_MAXIMUM_RESULTSConstant to let us know to include all records.- See Also:
-
-
Method Details
-
executeUpdate
int executeUpdate(StatementScope statementScope, Connection conn, String sql, Object[] parameters) throws SQLException Execute an update.- Parameters:
statementScope- - the request scopeconn- - the database connectionsql- - the sql statement to executeparameters- - the parameters for the sql statement- Returns:
- - the number of records changed
- Throws:
SQLException- - if the update fails
-
addBatch
void addBatch(StatementScope statementScope, Connection conn, String sql, Object[] parameters) throws SQLException Adds a statement to a batch.- Parameters:
statementScope- - the request scopeconn- - the database connectionsql- - the sql statementparameters- - the parameters for the statement- Throws:
SQLException- - if the statement fails
-
executeBatch
Execute a batch of statements.- Parameters:
sessionScope- - the session scope- Returns:
- - the number of rows impacted by the batch
- Throws:
SQLException- - if a statement fails
-
executeBatchDetailed
Execute a batch of statements.- Parameters:
sessionScope- - the session scope- Returns:
- - a List of BatchResult objects (may be null if no batch has been initiated). There will be one BatchResult object in the list for each sub-batch executed
- Throws:
SQLException- if a database access error occurs, or the drive does not support batch statementsBatchException- if the driver throws BatchUpdateException
-
executeQuery
void executeQuery(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException Long form of the method to execute a query.- Parameters:
statementScope- - the request scopeconn- - the database connectionsql- - the SQL statement to executeparameters- - the parameters for the statementskipResults- - the number of results to skipmaxResults- - the maximum number of results to returncallback- - the row handler for the query- Throws:
SQLException- - if the query fails
-
executeUpdateProcedure
int executeUpdateProcedure(StatementScope statementScope, Connection conn, String sql, Object[] parameters) throws SQLException Execute a stored procedure that updates data.- Parameters:
statementScope- - the request scopeconn- - the database connectionsql- - the SQL to call the procedureparameters- - the parameters for the procedure- Returns:
- - the rows impacted by the procedure
- Throws:
SQLException- - if the procedure fails
-
executeQueryProcedure
void executeQueryProcedure(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException Execute a stored procedure.- Parameters:
statementScope- - the request scopeconn- - the database connectionsql- - the sql to call the procedureparameters- - the parameters for the procedureskipResults- - the number of results to skipmaxResults- - the maximum number of results to returncallback- - a row handler for processing the results- Throws:
SQLException- - if the procedure fails
-
cleanup
Clean up any batches on the session.- Parameters:
sessionScope- - the session to clean up
-
init
Initializing SQL Executor by passing configuration and global properties.- Parameters:
config- - the configuration class, which contains complete configuration infoglobalProps- the global props
-