public class SqlExecutor extends Object
| Constructor and Description |
|---|
SqlExecutor() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
call(Connection conn,
String sql,
Object... params)
执行调用存储过程
此方法不会关闭Connection |
static ResultSet |
callQuery(Connection conn,
String sql,
Object... params)
执行调用存储过程
此方法不会关闭Connection |
static int |
execute(Connection conn,
String sql,
Map<String,Object> paramMap)
执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭Connection |
static int |
execute(Connection conn,
String sql,
Object... params)
执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭Connection |
static boolean |
execute(PreparedStatement ps,
Object... params)
可用于执行任何SQL语句,返回一个boolean值,表明执行该SQL语句是否返回了ResultSet。
|
static int[] |
executeBatch(Connection conn,
Iterable<String> sqls)
批量执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭Connection |
static int[] |
executeBatch(Connection conn,
String... sqls)
批量执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭Connection |
static int[] |
executeBatch(Connection conn,
String sql,
Iterable<Object[]> paramsBatch)
批量执行非查询语句
语句包括 插入、更新、删除 此方法不会关闭Connection |
static int[] |
executeBatch(Connection conn,
String sql,
Object[]... paramsBatch)
Deprecated.
重载导致编译器无法区分
|
static Long |
executeForGeneratedKey(Connection conn,
String sql,
Map<String,Object> paramMap)
执行非查询语句,返回主键
发查询语句包括 插入、更新、删除 此方法不会关闭Connection |
static Long |
executeForGeneratedKey(Connection conn,
String sql,
Object... params)
执行非查询语句,返回主键
发查询语句包括 插入、更新、删除 此方法不会关闭Connection |
static int |
executeUpdate(PreparedStatement ps,
Object... params)
用于执行 INSERT、UPDATE 或 DELETE 语句以及 SQL DDL(数据定义语言)语句,例如 CREATE TABLE 和 DROP TABLE。
|
static <T> T |
query(Connection conn,
Func1<Connection,PreparedStatement> statementFunc,
RsHandler<T> rsh)
|
static <T> T |
query(Connection conn,
SqlBuilder sqlBuilder,
RsHandler<T> rsh)
执行查询语句
此方法不会关闭Connection |
static <T> T |
query(Connection conn,
String sql,
RsHandler<T> rsh,
Map<String,Object> paramMap)
执行查询语句,例如:select * from table where field1=:name1
此方法不会关闭Connection |
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, Map<String,Object> paramMap) throws SQLException
conn - 数据库连接对象sql - SQL,使用name做为占位符,例如:nameparamMap - 参数MapSQLException - SQL执行异常public static int execute(Connection conn, String sql, Object... params) throws SQLException
conn - 数据库连接对象sql - SQLparams - 参数SQLException - SQL执行异常public static boolean call(Connection conn, String sql, Object... params) throws SQLException
conn - 数据库连接对象sql - SQLparams - 参数SQLException - SQL执行异常public static ResultSet callQuery(Connection conn, String sql, Object... params) throws SQLException
conn - 数据库连接对象sql - SQLparams - 参数SQLException - SQL执行异常public static Long executeForGeneratedKey(Connection conn, String sql, Map<String,Object> paramMap) throws SQLException
conn - 数据库连接对象sql - SQLparamMap - 参数MapSQLException - SQL执行异常public static Long executeForGeneratedKey(Connection conn, String sql, Object... params) throws SQLException
conn - 数据库连接对象sql - SQLparams - 参数SQLException - SQL执行异常@Deprecated public static int[] executeBatch(Connection conn, String sql, Object[]... paramsBatch) throws SQLException
conn - 数据库连接对象sql - SQLparamsBatch - 批量的参数SQLException - SQL执行异常public static int[] executeBatch(Connection conn, String sql, Iterable<Object[]> paramsBatch) throws SQLException
conn - 数据库连接对象sql - SQLparamsBatch - 批量的参数SQLException - SQL执行异常public static int[] executeBatch(Connection conn, String... sqls) throws SQLException
conn - 数据库连接对象sqls - SQL列表SQLException - SQL执行异常public static int[] executeBatch(Connection conn, Iterable<String> sqls) throws SQLException
conn - 数据库连接对象sqls - SQL列表SQLException - SQL执行异常public static <T> T query(Connection conn, String sql, RsHandler<T> rsh, Map<String,Object> paramMap) throws SQLException
T - 处理结果类型conn - 数据库连接对象sql - 查询语句,使用参数名占位符,例如:namersh - 结果集处理对象paramMap - 参数对SQLException - SQL执行异常public static <T> T query(Connection conn, SqlBuilder sqlBuilder, RsHandler<T> rsh) throws SQLException
T - 处理结果类型conn - 数据库连接对象sqlBuilder - SQL构建器,包含参数rsh - 结果集处理对象SQLException - SQL执行异常public static <T> T query(Connection conn, String sql, RsHandler<T> rsh, Object... params) throws SQLException
T - 处理结果类型conn - 数据库连接对象sql - 查询语句rsh - 结果集处理对象params - 参数SQLException - SQL执行异常public static <T> T query(Connection conn, Func1<Connection,PreparedStatement> statementFunc, RsHandler<T> rsh) throws SQLException
T - 处理结果类型conn - 数据库连接对象statementFunc - 自定义PreparedStatement创建函数rsh - 自定义结果集处理SQLException - SQL执行异常public static int executeUpdate(PreparedStatement ps, Object... params) throws SQLException
ps - PreparedStatement对象params - 参数SQLException - SQL执行异常public static boolean execute(PreparedStatement ps, Object... params) throws SQLException
ps - PreparedStatement对象params - 参数SQLException - SQL执行异常public static <T> T query(PreparedStatement ps, RsHandler<T> rsh, Object... params) throws SQLException
T - 处理结果类型ps - PreparedStatementrsh - 结果集处理对象params - 参数SQLException - SQL执行异常public static <T> T queryAndClosePs(PreparedStatement ps, RsHandler<T> rsh, Object... params) throws SQLException
T - 处理结果类型ps - PreparedStatementrsh - 结果集处理对象params - 参数SQLException - SQL执行异常Copyright © 2025. All rights reserved.