mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
fix:持久化模块的小bug
add:持久化模块的新单元测试
This commit is contained in:
1 parent
442b4e3544
commit
dcde4eeb41
6 files changed
+242
-135
No files matched your search
@@ -36,12 +36,16 @@ public class Sqlite {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将密码转换为16进制表示
|
||||
* @return 16进制字符串 String
|
||||
*/
|
||||
private String passwd2HexKey(){
|
||||
return String.format("x'%s'", passwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Sqlite object
|
||||
* 获取Sqlite 实例
|
||||
* @return Sqlite object
|
||||
*/
|
||||
public static Sqlite getInstance() {
|
||||
@@ -90,10 +94,19 @@ public class Sqlite {
|
||||
}
|
||||
}
|
||||
//自定义文件地址,注意要用/结尾,比如:/min/identity/
|
||||
|
||||
/**
|
||||
* 打开用户指定路径的数据库文件
|
||||
* @param filePath String
|
||||
* @throws Exception
|
||||
*/
|
||||
public void open(String filePath) throws Exception {
|
||||
Connection c = null;
|
||||
Statement stmt = null;
|
||||
try{
|
||||
if (filePath == null || filePath.length() == 0){
|
||||
throw new Exception("invalid db path!");
|
||||
}
|
||||
db_path = filePath;
|
||||
boolean db_exists = SqliteUtil.pathExists(db_path);
|
||||
if (!db_exists){
|
||||
@@ -114,6 +127,11 @@ public class Sqlite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从打开的数据库获取连接
|
||||
* @return Connection
|
||||
* @throws Exception
|
||||
*/
|
||||
public Connection getConn() throws Exception {
|
||||
Connection c = null;
|
||||
try{
|
||||
|
||||
Reference in new issue
Block a user