com.ibatis.sqlmap.engine.execution
Class SqlExecutor

java.lang.Object
  extended bycom.ibatis.sqlmap.engine.execution.SqlExecutor

public class SqlExecutor
extends java.lang.Object

Class responsible for executing the SQL


Field Summary
static int NO_MAXIMUM_RESULTS
          Constant to let us know to include all records
static int NO_SKIPPED_RESULTS
          Constant to let us know not to skip anything
 
Constructor Summary
SqlExecutor()
           
 
Method Summary
 void addBatch(RequestScope request, java.sql.Connection conn, java.lang.String sql, java.lang.Object[] parameters)
          Adds a statement to a batch
 void cleanup(SessionScope session)
          Clean up any batches on the session
 int executeBatch(SessionScope session)
          Execute a batch of statements
 java.util.List executeBatchDetailed(SessionScope session)
          Execute a batch of statements
 void executeQuery(RequestScope request, java.sql.Connection conn, java.lang.String sql, java.lang.Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback)
          Long form of the method to execute a query
 void executeQueryProcedure(RequestScope request, java.sql.Connection conn, java.lang.String sql, java.lang.Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback)
          Execute a stored procedure
 int executeUpdate(RequestScope request, java.sql.Connection conn, java.lang.String sql, java.lang.Object[] parameters)
          Execute an update
 int executeUpdateProcedure(RequestScope request, java.sql.Connection conn, java.lang.String sql, java.lang.Object[] parameters)
          Execute a stored procedure that updates data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_SKIPPED_RESULTS

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

See Also:
Constant Field Values

NO_MAXIMUM_RESULTS

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

See Also:
Constant Field Values
Constructor Detail

SqlExecutor

public SqlExecutor()
Method Detail

executeUpdate

public int executeUpdate(RequestScope request,
                         java.sql.Connection conn,
                         java.lang.String sql,
                         java.lang.Object[] parameters)
                  throws java.sql.SQLException
Execute an update

Parameters:
request - - 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:
java.sql.SQLException - - if the update fails

addBatch

public void addBatch(RequestScope request,
                     java.sql.Connection conn,
                     java.lang.String sql,
                     java.lang.Object[] parameters)
              throws java.sql.SQLException
Adds a statement to a batch

Parameters:
request - - the request scope
conn - - the database connection
sql - - the sql statement
parameters - - the parameters for the statement
Throws:
java.sql.SQLException - - if the statement fails

executeBatch

public int executeBatch(SessionScope session)
                 throws java.sql.SQLException
Execute a batch of statements

Parameters:
session - - the session scope
Returns:
- the number of rows impacted by the batch
Throws:
java.sql.SQLException - - if a statement fails

executeBatchDetailed

public java.util.List executeBatchDetailed(SessionScope session)
                                    throws java.sql.SQLException,
                                           BatchException
Execute a batch of statements

Parameters:
session - - 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:
java.sql.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(RequestScope request,
                         java.sql.Connection conn,
                         java.lang.String sql,
                         java.lang.Object[] parameters,
                         int skipResults,
                         int maxResults,
                         RowHandlerCallback callback)
                  throws java.sql.SQLException
Long form of the method to execute a query

Parameters:
request - - 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:
java.sql.SQLException - - if the query fails

executeUpdateProcedure

public int executeUpdateProcedure(RequestScope request,
                                  java.sql.Connection conn,
                                  java.lang.String sql,
                                  java.lang.Object[] parameters)
                           throws java.sql.SQLException
Execute a stored procedure that updates data

Parameters:
request - - 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:
java.sql.SQLException - - if the procedure fails

executeQueryProcedure

public void executeQueryProcedure(RequestScope request,
                                  java.sql.Connection conn,
                                  java.lang.String sql,
                                  java.lang.Object[] parameters,
                                  int skipResults,
                                  int maxResults,
                                  RowHandlerCallback callback)
                           throws java.sql.SQLException
Execute a stored procedure

Parameters:
request - - 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:
java.sql.SQLException - - if the procedure fails

cleanup

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

Parameters:
session - - the session to clean up