类 SqliteHelper
- java.lang.Object
-
- cn.smartjavaai.face.sqllite.SqliteHelper
-
public class SqliteHelper extends Object
sqlite帮助类- 作者:
- dwj
-
-
构造器概要
构造器 构造器 说明 SqliteHelper(String dbFilePath)构造函数
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voiddestroyed()数据库资源关闭和释放intexecuteInsertOrUpdate(String tableName, Map<String,Object> param)执行数据库更新sql语句StringexecuteQuery(String sql)简单查询某个字段<T> TexecuteQuery(String sql, ResultSetExtractor<T> rse)执行sql查询<T> List<T>executeQuery(String sql, RowMapper<T> rm)执行select查询,返回结果列表<T> TexecuteQuery(String sql, Class<T> clazz)执行sql查询,适用单条结果集<T> List<T>executeQueryList(String sql, Class<T> clazz)执行select查询,返回结果列表intexecuteUpdate(String sql)执行数据库更新sql语句voidexecuteUpdate(String... sqls)执行多个sql更新语句intexecuteUpdate(String sql, Object[] args)voidexecuteUpdate(List<String> sqls)执行数据库更新 sql ListConnectiongetConnection(String dbFilePath)获取数据库连接
-
-
-
构造器详细资料
-
SqliteHelper
public SqliteHelper(String dbFilePath) throws ClassNotFoundException, SQLException
构造函数- 参数:
dbFilePath- sqlite db 文件路径- 抛出:
ClassNotFoundExceptionSQLException
-
-
方法详细资料
-
getConnection
public Connection getConnection(String dbFilePath) throws ClassNotFoundException, SQLException
获取数据库连接- 参数:
dbFilePath- db文件路径- 返回:
- 数据库连接
- 抛出:
ClassNotFoundExceptionSQLException
-
executeQuery
public <T> T executeQuery(String sql, ResultSetExtractor<T> rse) throws SQLException, ClassNotFoundException
执行sql查询- 参数:
sql- sql select 语句rse- 结果集处理类对象- 返回:
- 查询结果
- 抛出:
SQLExceptionClassNotFoundException
-
executeQuery
public <T> List<T> executeQuery(String sql, RowMapper<T> rm) throws SQLException, ClassNotFoundException
执行select查询,返回结果列表- 参数:
sql- sql select 语句rm- 结果集的行数据处理类对象- 返回:
- 抛出:
SQLExceptionClassNotFoundException
-
executeQuery
public String executeQuery(String sql) throws SQLException, ClassNotFoundException
简单查询某个字段- 参数:
sql-- 返回:
- 抛出:
SQLExceptionClassNotFoundException
-
executeUpdate
public int executeUpdate(String sql) throws SQLException, ClassNotFoundException
执行数据库更新sql语句- 参数:
sql-- 返回:
- 更新行数
- 抛出:
SQLExceptionClassNotFoundException
-
executeUpdate
public void executeUpdate(String... sqls) throws SQLException, ClassNotFoundException
执行多个sql更新语句- 参数:
sqls-- 抛出:
SQLExceptionClassNotFoundException
-
executeUpdate
public void executeUpdate(List<String> sqls) throws SQLException, ClassNotFoundException
执行数据库更新 sql List- 参数:
sqls- sql列表- 抛出:
SQLExceptionClassNotFoundException
-
destroyed
public void destroyed()
数据库资源关闭和释放
-
executeQueryList
public <T> List<T> executeQueryList(String sql, Class<T> clazz) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException
执行select查询,返回结果列表- 参数:
sql- sql select 语句clazz- 实体泛型- 返回:
- 实体集合
- 抛出:
SQLException- 异常信息ClassNotFoundException- 异常信息IllegalAccessExceptionInstantiationException
-
executeQuery
public <T> T executeQuery(String sql, Class<T> clazz) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException
执行sql查询,适用单条结果集- 参数:
sql- sql select 语句clazz- 结果集处理类对象- 返回:
- 查询结果
- 抛出:
SQLExceptionClassNotFoundExceptionIllegalAccessExceptionInstantiationException
-
executeInsertOrUpdate
public int executeInsertOrUpdate(String tableName, Map<String,Object> param) throws SQLException, ClassNotFoundException
执行数据库更新sql语句- 参数:
tableName- 表名param- key-value键值对,key:表中字段名,value:值- 返回:
- 更新行数
- 抛出:
SQLExceptionClassNotFoundException
-
executeUpdate
public int executeUpdate(String sql, Object[] args) throws SQLException, ClassNotFoundException
-
-