Package org.apache.ibatis.jdbc
Class SqlRunner
- java.lang.Object
- 
- org.apache.ibatis.jdbc.SqlRunner
 
- 
 public class SqlRunner extends java.lang.Object- Author:
- Clinton Begin
 
- 
- 
Field SummaryFields Modifier and Type Field Description static intNO_GENERATED_KEY
 - 
Constructor SummaryConstructors Constructor Description SqlRunner(java.sql.Connection connection)
 - 
Method SummaryModifier and Type Method Description voidcloseConnection()Deprecated.Since 3.5.4, this method is deprecated.intdelete(java.lang.String sql, java.lang.Object... args)Executes a DELETE statement.intinsert(java.lang.String sql, java.lang.Object... args)Executes an INSERT statement.voidrun(java.lang.String sql)Executes any string as a JDBC Statement.java.util.List<java.util.Map<java.lang.String,java.lang.Object>>selectAll(java.lang.String sql, java.lang.Object... args)Executes a SELECT statement that returns multiple rows.java.util.Map<java.lang.String,java.lang.Object>selectOne(java.lang.String sql, java.lang.Object... args)Executes a SELECT statement that returns one row.voidsetUseGeneratedKeySupport(boolean useGeneratedKeySupport)intupdate(java.lang.String sql, java.lang.Object... args)Executes an UPDATE statement.
 
- 
- 
- 
Field Detail- 
NO_GENERATED_KEYpublic static final int NO_GENERATED_KEY - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
setUseGeneratedKeySupportpublic void setUseGeneratedKeySupport(boolean useGeneratedKeySupport) 
 - 
selectOnepublic java.util.Map<java.lang.String,java.lang.Object> selectOne(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLExceptionExecutes 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:
- java.sql.SQLException- If less or more than one row is returned
 
 - 
selectAllpublic java.util.List<java.util.Map<java.lang.String,java.lang.Object>> selectAll(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLExceptionExecutes 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:
- java.sql.SQLException- If statement preparation or execution fails
 
 - 
insertpublic int insert(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLExceptionExecutes 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:
- java.sql.SQLException- If statement preparation or execution fails
 
 - 
updatepublic int update(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLExceptionExecutes 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:
- java.sql.SQLException- If statement preparation or execution fails
 
 - 
deletepublic int delete(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLExceptionExecutes 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:
- java.sql.SQLException- If statement preparation or execution fails
 
 - 
runpublic void run(java.lang.String sql) throws java.sql.SQLExceptionExecutes any string as a JDBC Statement. Good for DDL- Parameters:
- sql- The SQL
- Throws:
- java.sql.SQLException- If statement preparation or execution fails
 
 - 
closeConnection@Deprecated public void closeConnection() Deprecated.Since 3.5.4, this method is deprecated. Please close theConnectionoutside of this class.
 
- 
 
-