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 Summary
Fields Modifier and Type Field Description static int
NO_GENERATED_KEY
-
Constructor Summary
Constructors Constructor Description SqlRunner(java.sql.Connection connection)
-
Method Summary
Modifier and Type Method Description void
closeConnection()
Deprecated.Since 3.5.4, this method is deprecated.int
delete(java.lang.String sql, java.lang.Object... args)
Executes a DELETE statement.int
insert(java.lang.String sql, java.lang.Object... args)
Executes an INSERT statement.void
run(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.void
setUseGeneratedKeySupport(boolean useGeneratedKeySupport)
int
update(java.lang.String sql, java.lang.Object... args)
Executes an UPDATE statement.
-
-
-
Field Detail
-
NO_GENERATED_KEY
public static final int NO_GENERATED_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
setUseGeneratedKeySupport
public void setUseGeneratedKeySupport(boolean useGeneratedKeySupport)
-
selectOne
public java.util.Map<java.lang.String,java.lang.Object> selectOne(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLException
Executes a SELECT statement that returns one row.- Parameters:
sql
- The SQLargs
- 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
-
selectAll
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> selectAll(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLException
Executes a SELECT statement that returns multiple rows.- Parameters:
sql
- The SQLargs
- The arguments to be set on the statement.- Returns:
- The list of rows expected.
- Throws:
java.sql.SQLException
- If statement preparation or execution fails
-
insert
public int insert(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLException
Executes an INSERT statement.- Parameters:
sql
- The SQLargs
- 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
-
update
public int update(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLException
Executes an UPDATE statement.- Parameters:
sql
- The SQLargs
- 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
-
delete
public int delete(java.lang.String sql, java.lang.Object... args) throws java.sql.SQLException
Executes a DELETE statement.- Parameters:
sql
- The SQLargs
- 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
-
run
public void run(java.lang.String sql) throws java.sql.SQLException
Executes 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 theConnection
outside of this class.
-
-