Class DefaultSqlExecutor
java.lang.Object
com.ibatis.sqlmap.engine.execution.DefaultSqlExecutor
- All Implemented Interfaces:
SqlExecutor
Class responsible for executing the SQL.
-
Field Summary
Fields inherited from interface com.ibatis.sqlmap.engine.execution.SqlExecutor
NO_MAXIMUM_RESULTS, NO_SKIPPED_RESULTS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBatch
(StatementScope statementScope, Connection conn, String sql, Object[] parameters) Adds a statement to a batchvoid
cleanup
(SessionScope sessionScope) Clean up any batches on the sessionint
executeBatch
(SessionScope sessionScope) Execute a batch of statementsexecuteBatchDetailed
(SessionScope sessionScope) Execute a batch of statementsvoid
executeQuery
(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) Long form of the method to execute a queryvoid
executeQueryProcedure
(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) Execute a stored procedureint
executeUpdate
(StatementScope statementScope, Connection conn, String sql, Object[] parameters) Execute an updateint
executeUpdateProcedure
(StatementScope statementScope, Connection conn, String sql, Object[] parameters) Execute a stored procedure that updates datavoid
init
(SqlMapConfiguration config, Properties globalProps) Initializing SQL Executor by passing configuration and global properties.
-
Constructor Details
-
DefaultSqlExecutor
public DefaultSqlExecutor()
-
-
Method Details
-
executeUpdate
public int executeUpdate(StatementScope statementScope, Connection conn, String sql, Object[] parameters) throws SQLException Execute an update- Specified by:
executeUpdate
in interfaceSqlExecutor
- 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
public void addBatch(StatementScope statementScope, Connection conn, String sql, Object[] parameters) throws SQLException Adds a statement to a batch- Specified by:
addBatch
in interfaceSqlExecutor
- 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- Specified by:
executeBatch
in interfaceSqlExecutor
- 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- Specified by:
executeBatchDetailed
in interfaceSqlExecutor
- 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
public 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- Specified by:
executeQuery
in interfaceSqlExecutor
- 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
public int executeUpdateProcedure(StatementScope statementScope, Connection conn, String sql, Object[] parameters) throws SQLException Execute a stored procedure that updates data- Specified by:
executeUpdateProcedure
in interfaceSqlExecutor
- 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
public void executeQueryProcedure(StatementScope statementScope, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException Execute a stored procedure- Specified by:
executeQueryProcedure
in interfaceSqlExecutor
- 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
-
init
Description copied from interface:SqlExecutor
Initializing SQL Executor by passing configuration and global properties.- Specified by:
init
in interfaceSqlExecutor
- Parameters:
config
- - the configuration class, which contains complete configuration infoglobalProps
- the global props
-
cleanup
Clean up any batches on the session- Specified by:
cleanup
in interfaceSqlExecutor
- Parameters:
sessionScope
- - the session to clean up
-