org.apache.ibatis.jdbc
Class SqlRunner

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

public class SqlRunner
extends Object


Field Summary
static int NO_GENERATED_KEY
           
 
Constructor Summary
SqlRunner(Connection connection)
           
 
Method Summary
 void closeConnection()
           
 int delete(String sql, Object... args)
          Executes a DELETE statement.
 int insert(String sql, Object... args)
          Executes an INSERT statement.
 void run(String sql)
          Executes any string as a JDBC Statement.
 List<Map<String,Object>> selectAll(String sql, Object... args)
          Executes a SELECT statement that returns multiple rows.
 Map<String,Object> selectOne(String sql, Object... args)
          Executes a SELECT statement that returns one row.
 void setUseGeneratedKeySupport(boolean useGeneratedKeySupport)
           
 int update(String sql, Object... args)
          Executes an UPDATE statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_GENERATED_KEY

public static final int NO_GENERATED_KEY
See Also:
Constant Field Values
Constructor Detail

SqlRunner

public SqlRunner(Connection connection)
Method Detail

setUseGeneratedKeySupport

public void setUseGeneratedKeySupport(boolean useGeneratedKeySupport)

selectOne

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 number of rows impacted or BATCHED_RESULTS if the statements are being batched.
Throws:
SQLException - If more than one row is returned

selectAll

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 number of rows impacted or BATCHED_RESULTS if the statements are being batched.
Throws:
SQLException - If statement prepration or execution fails

insert

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 prepration or execution fails

update

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 prepration or execution fails

delete

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 prepration or execution fails

run

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 prepration or execution fails

closeConnection

public void closeConnection()


Copyright © 2010. All Rights Reserved.