com.ibatis.sqlmap.engine.execution

Class SqlExecutor

public class SqlExecutor extends Object

Class responsible for executing the SQL
Field Summary
static intNO_MAXIMUM_RESULTS
Constant to let us know to include all records
static intNO_SKIPPED_RESULTS
Constant to let us know not to skip anything
Method Summary
voidaddBatch(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
ListexecuteBatchDetailed(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

Field Detail

NO_MAXIMUM_RESULTS

public static final int NO_MAXIMUM_RESULTS
Constant to let us know to include all records

NO_SKIPPED_RESULTS

public static final int NO_SKIPPED_RESULTS
Constant to let us know not to skip anything

Method Detail

addBatch

public void addBatch(StatementScope statementScope, Connection conn, String sql, Object[] parameters)
Adds a statement to a batch

Parameters: statementScope - the request scope conn - the database connection sql - the sql statement parameters - the parameters for the statement

Throws: SQLException - if the statement fails

cleanup

public void cleanup(SessionScope sessionScope)
Clean up any batches on the session

Parameters: sessionScope - the session to clean up

executeBatch

public int executeBatch(SessionScope sessionScope)
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

public List executeBatchDetailed(SessionScope sessionScope)
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 statements BatchException if the driver throws BatchUpdateException

executeQuery

public void executeQuery(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback)
Long form of the method to execute a query

Parameters: statementScope - the request scope conn - the database connection sql - the SQL statement to execute parameters - the parameters for the statement skipResults - the number of results to skip maxResults - the maximum number of results to return callback - the row handler for the query

Throws: SQLException - if the query fails

executeQueryProcedure

public void executeQueryProcedure(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback)
Execute a stored procedure

Parameters: statementScope - the request scope conn - the database connection sql - the sql to call the procedure parameters - the parameters for the procedure skipResults - the number of results to skip maxResults - the maximum number of results to return callback - a row handler for processing the results

Throws: SQLException - if the procedure fails

executeUpdate

public int executeUpdate(StatementScope statementScope, Connection conn, String sql, Object[] parameters)
Execute an update

Parameters: statementScope - the request scope conn - the database connection sql - the sql statement to execute parameters - the parameters for the sql statement

Returns: - the number of records changed

Throws: SQLException - if the update fails

executeUpdateProcedure

public int executeUpdateProcedure(StatementScope statementScope, Connection conn, String sql, Object[] parameters)
Execute a stored procedure that updates data

Parameters: statementScope - the request scope conn - the database connection sql - the SQL to call the procedure parameters - the parameters for the procedure

Returns: - the rows impacted by the procedure

Throws: SQLException - if the procedure fails

Copyright © 2011. All Rights Reserved.