Class DefaultSqlExecutor

java.lang.Object
com.ibatis.sqlmap.engine.execution.DefaultSqlExecutor
All Implemented Interfaces:
SqlExecutor

public class DefaultSqlExecutor extends Object implements SqlExecutor
Class responsible for executing the SQL.
  • 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 interface SqlExecutor
      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
    • addBatch

      public void addBatch(StatementScope statementScope, Connection conn, String sql, Object[] parameters) throws SQLException
      Adds a statement to a batch
      Specified by:
      addBatch in interface SqlExecutor
      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
    • executeBatch

      public int executeBatch(SessionScope sessionScope) throws SQLException
      Execute a batch of statements
      Specified by:
      executeBatch in interface SqlExecutor
      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) throws SQLException, BatchException
      Execute a batch of statements
      Specified by:
      executeBatchDetailed in interface SqlExecutor
      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) throws SQLException
      Long form of the method to execute a query
      Specified by:
      executeQuery in interface SqlExecutor
      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
    • 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 interface SqlExecutor
      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
    • 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 interface SqlExecutor
      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
    • init

      public void init(SqlMapConfiguration config, Properties globalProps)
      Description copied from interface: SqlExecutor
      Initializing SQL Executor by passing configuration and global properties.
      Specified by:
      init in interface SqlExecutor
      Parameters:
      config - - the configuration class, which contains complete configuration info
      globalProps - the global props
    • cleanup

      public void cleanup(SessionScope sessionScope)
      Clean up any batches on the session
      Specified by:
      cleanup in interface SqlExecutor
      Parameters:
      sessionScope - - the session to clean up