Class SqlRunner

java.lang.Object
org.apache.ibatis.jdbc.SqlRunner

public class SqlRunner extends Object
Author:
Clinton Begin
  • Field Details Link icon

  • Constructor Details Link icon

    • SqlRunner Link icon

      public SqlRunner(Connection connection)
  • Method Details Link icon

    • setUseGeneratedKeySupport Link icon

      public void setUseGeneratedKeySupport(boolean useGeneratedKeySupport)
    • selectOne Link icon

      public Map<String,Object> selectOne(String sql, Object... args) throws SQLException
      Executes a SELECT statement that returns one row.
      Parameters:
      sql - The SQL
      args - The arguments to be set on the statement.
      Returns:
      The row expected.
      Throws:
      SQLException - If less or more than one row is returned
    • selectAll Link icon

      public List<Map<String,Object>> selectAll(String sql, Object... args) throws SQLException
      Executes a SELECT statement that returns multiple rows.
      Parameters:
      sql - The SQL
      args - The arguments to be set on the statement.
      Returns:
      The list of rows expected.
      Throws:
      SQLException - If statement preparation or execution fails
    • insert Link icon

      public int insert(String sql, Object... args) throws SQLException
      Executes an INSERT statement.
      Parameters:
      sql - The SQL
      args - The arguments to be set on the statement.
      Returns:
      The number of rows impacted or BATCHED_RESULTS if the statements are being batched.
      Throws:
      SQLException - If statement preparation or execution fails
    • update Link icon

      public int update(String sql, Object... args) throws SQLException
      Executes an UPDATE statement.
      Parameters:
      sql - The SQL
      args - The arguments to be set on the statement.
      Returns:
      The number of rows impacted or BATCHED_RESULTS if the statements are being batched.
      Throws:
      SQLException - If statement preparation or execution fails
    • delete Link icon

      public int delete(String sql, Object... args) throws SQLException
      Executes a DELETE statement.
      Parameters:
      sql - The SQL
      args - The arguments to be set on the statement.
      Returns:
      The number of rows impacted or BATCHED_RESULTS if the statements are being batched.
      Throws:
      SQLException - If statement preparation or execution fails
    • run Link icon

      public void run(String sql) throws SQLException
      Executes any string as a JDBC Statement. Good for DDL
      Parameters:
      sql - The SQL
      Throws:
      SQLException - If statement preparation or execution fails
    • closeConnection Link icon

      @Deprecated public void closeConnection()
      Deprecated.
      Since 3.5.4, this method is deprecated. Please close the Connection outside of this class.