public class SqlExecutor extends Object
| 构造器和说明 |
|---|
SqlExecutor() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
call(Connection conn,
String sql,
Object... params)
执行调用存储过程
此方法不会关闭Connection |
static int |
execute(Connection conn,
String sql,
Object... params)
执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭Connection |
static boolean |
execute(PreparedStatement ps,
Object... params)
执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭PreparedStatement |
static int[] |
executeBatch(Connection conn,
String sql,
Object[]... paramsBatch)
批量执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭Connection |
static Long |
executeForGeneratedKey(Connection conn,
String sql,
Object... params)
执行非查询语句,返回主键
发查询语句包括 插入、更新、删除 此方法不会关闭Connection |
static int |
executeUpdate(PreparedStatement ps,
Object... params)
执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭PreparedStatement |
static <T> T |
query(Connection conn,
String sql,
RsHandler<T> rsh,
Object... params)
执行查询语句
此方法不会关闭Connection |
static <T> T |
query(PreparedStatement ps,
RsHandler<T> rsh,
Object... params)
执行查询语句
此方法不会关闭PreparedStatement |
static <T> T |
queryAndClosePs(PreparedStatement ps,
RsHandler<T> rsh,
Object... params)
执行查询语句并关闭PreparedStatement
|
public static int execute(Connection conn, String sql, Object... params) throws SQLException
conn - 数据库连接对象sql - SQLparams - 参数SQLExceptionpublic static boolean call(Connection conn, String sql, Object... params) throws SQLException
conn - 数据库连接对象sql - SQLparams - 参数SQLExceptionpublic static Long executeForGeneratedKey(Connection conn, String sql, Object... params) throws SQLException
conn - 数据库连接对象sql - SQLparams - 参数SQLExceptionpublic static int[] executeBatch(Connection conn, String sql, Object[]... paramsBatch) throws SQLException
conn - 数据库连接对象sql - SQLparamsBatch - 批量的参数SQLExceptionpublic static <T> T query(Connection conn, String sql, RsHandler<T> rsh, Object... params) throws SQLException
conn - 数据库连接对象sql - 查询语句rsh - 结果集处理对象params - 参数SQLExceptionpublic static int executeUpdate(PreparedStatement ps, Object... params) throws SQLException
ps - PreparedStatement对象params - 参数SQLExceptionpublic static boolean execute(PreparedStatement ps, Object... params) throws SQLException
ps - PreparedStatement对象params - 参数SQLExceptionpublic static <T> T query(PreparedStatement ps, RsHandler<T> rsh, Object... params) throws SQLException
ps - PreparedStatementrsh - 结果集处理对象params - 参数SQLExceptionpublic static <T> T queryAndClosePs(PreparedStatement ps, RsHandler<T> rsh, Object... params) throws SQLException
ps - PreparedStatementrsh - 结果集处理对象params - 参数SQLExceptionCopyright © 2016. All rights reserved.