public class SqlRunner extends Object
Modifier and Type | Field and Description |
---|---|
static int |
NO_GENERATED_KEY |
Constructor and Description |
---|
SqlRunner(Connection connection) |
Modifier and Type | Method and Description |
---|---|
void |
closeConnection()
Deprecated.
Since 3.5.4, this method is deprecated. Please close the
Connection outside of this class. |
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.
|
public static final int NO_GENERATED_KEY
public SqlRunner(Connection connection)
public void setUseGeneratedKeySupport(boolean useGeneratedKeySupport)
public Map<String,Object> selectOne(String sql, Object... args) throws SQLException
sql
- The SQLargs
- The arguments to be set on the statement.SQLException
- If less or more than one row is returnedpublic List<Map<String,Object>> selectAll(String sql, Object... args) throws SQLException
sql
- The SQLargs
- The arguments to be set on the statement.SQLException
- If statement preparation or execution failspublic int insert(String sql, Object... args) throws SQLException
sql
- The SQLargs
- The arguments to be set on the statement.SQLException
- If statement preparation or execution failspublic int update(String sql, Object... args) throws SQLException
sql
- The SQLargs
- The arguments to be set on the statement.SQLException
- If statement preparation or execution failspublic int delete(String sql, Object... args) throws SQLException
sql
- The SQLargs
- The arguments to be set on the statement.SQLException
- If statement preparation or execution failspublic void run(String sql) throws SQLException
sql
- The SQLSQLException
- If statement preparation or execution fails@Deprecated public void closeConnection()
Connection
outside of this class.Copyright © 2009–2021 MyBatis.org. All rights reserved.