|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.xiaoleilu.hutool.db.SqlExecutor
com.xiaoleilu.hutool.db.SqlConnRunner
com.xiaoleilu.hutool.db.SqlRunner
public class SqlRunner
SQL执行类
通过给定的数据源执行给定SQL或者给定数据源和方言,执行相应的CRUD操作
| 构造方法摘要 | |
|---|---|
SqlRunner(DataSource ds)
构造,从DataSource中识别方言 |
|
SqlRunner(DataSource ds,
Dialect dialect)
构造 |
|
SqlRunner(DataSource ds,
String driverClassName)
构造 |
|
| 方法摘要 | ||
|---|---|---|
int |
count(Entity where)
结果的条目数 |
|
static SqlRunner |
create(DataSource ds)
创建SqlRunner 会根据数据源连接的元信息识别目标数据库类型,进而使用合适的数据源 |
|
static SqlRunner |
create(DataSource ds,
Dialect dialect)
创建SqlRunner |
|
static SqlRunner |
create(DataSource ds,
String driverClassName)
创建SqlRunner |
|
int |
del(Entity where)
删除数据 |
|
int |
execute(String sql,
Object... params)
执行非查询语句 语句包括 插入、更新、删除 |
|
int[] |
executeBatch(String sql,
Object[]... paramsBatch)
批量执行非查询语句 |
|
Long |
executeForGeneratedKey(String sql,
Object... params)
执行非查询语句 语句包括 插入、更新、删除 |
|
|
find(Collection<String> fields,
Entity where,
RsHandler<T> rsh)
查询 |
|
Long |
insert(Entity record)
插入数据 |
|
|
page(Collection<String> fields,
Entity where,
int page,
int numPerPage,
RsHandler<T> rsh)
分页查询 |
|
|
query(String sql,
RsHandler<T> rsh,
Object... params)
查询 |
|
int |
update(Entity record,
Entity where)
更新数据 |
|
| 从类 com.xiaoleilu.hutool.db.SqlConnRunner 继承的方法 |
|---|
count, del, find, insert, page, update |
| 从类 com.xiaoleilu.hutool.db.SqlExecutor 继承的方法 |
|---|
execute, executeBatch, executeForGeneratedKey, query |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public SqlRunner(DataSource ds)
ds - 数据源
public SqlRunner(DataSource ds,
Dialect dialect)
ds - 数据源dialect - 方言
public SqlRunner(DataSource ds,
String driverClassName)
ds - 数据源driverClassName - 数据库连接驱动类名,用于识别方言| 方法详细信息 |
|---|
public static SqlRunner create(DataSource ds)
ds - 数据源
public static SqlRunner create(DataSource ds,
Dialect dialect)
ds - 数据源dialect - 方言
public static SqlRunner create(DataSource ds,
String driverClassName)
ds - 数据源driverClassName - 数据库连接驱动类名
public <T> T query(String sql,
RsHandler<T> rsh,
Object... params)
throws SQLException
sql - 查询语句rsh - 结果集处理对象params - 参数
SQLException
public int execute(String sql,
Object... params)
throws SQLException
sql - SQLparams - 参数
SQLException
public Long executeForGeneratedKey(String sql,
Object... params)
throws SQLException
sql - SQLparams - 参数
SQLException
public int[] executeBatch(String sql,
Object[]... paramsBatch)
throws SQLException
sql - SQLparamsBatch - 批量的参数
SQLException
public Long insert(Entity record)
throws SQLException
record - 记录
SQLException
public int del(Entity where)
throws SQLException
where - 条件
SQLException
public int update(Entity record,
Entity where)
throws SQLException
record - 记录
SQLException
public <T> T find(Collection<String> fields,
Entity where,
RsHandler<T> rsh)
throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)rsh - 结果集处理对象
SQLException
public <T> T page(Collection<String> fields,
Entity where,
int page,
int numPerPage,
RsHandler<T> rsh)
throws SQLException
fields - 返回的字段列表,null则返回所有字段where - 条件实体类(包含表名)page - 页码numPerPage - 每页条目数rsh - 结果集处理对象
SQLException
public int count(Entity where)
throws SQLException
where - 查询条件
SQLException
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||