mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
Merge branch 'master' of gitee.com:willfree/min-dev-java
This commit is contained in:
commit
036c4d3dc9
6 files changed
+119
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package minsecurity.identity.persist.sqlite;
|
||||
|
||||
/*
|
||||
* @Author: zhengqi wu
|
||||
* @Description: Sqlite封装
|
||||
* @Version: 1.0.0
|
||||
* @Date: 22:34 2021/04/01
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
// 存在配置信息,使用单例模式封装工具类
|
||||
public class Sqlite {
|
||||
private static final Sqlite Instance = new Sqlite(); // sqlite 唯一object
|
||||
|
||||
private String passwd = "2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99"; // 初始数据库密码
|
||||
private String db_file = "identity.db"; // 数据库文件名
|
||||
private Sqlite(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Sqlite object
|
||||
* @return Sqlite object
|
||||
*/
|
||||
public static Sqlite getInstance() {
|
||||
return Instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据库的连接密码
|
||||
* @param pass 新密码
|
||||
* @throws Exception
|
||||
*/
|
||||
public void setPasswd(String pass) throws Exception {
|
||||
if (pass.length() != 64){
|
||||
throw new Exception("Invalid Length");
|
||||
}
|
||||
passwd = pass;
|
||||
}
|
||||
|
||||
public void open(String filePath){
|
||||
try{
|
||||
boolean db_exists = SqliteUtil.pathExists(filePath);
|
||||
if (!db_exists){
|
||||
|
||||
}
|
||||
String real_db_file = filePath + db_file;
|
||||
|
||||
}catch (Exception ex){
|
||||
// TODO 出错时关闭数据库
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package minsecurity.identity.persist.sqlite;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/*
|
||||
* @Author: zhengqi wu
|
||||
* @Description: sqlite工具类封装
|
||||
* @Version: 1.0.0
|
||||
* @Date: 10:34 2021/03/10
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
|
||||
// 无配置信息,采用静态类
|
||||
public final class SqliteUtil {
|
||||
// Home returns the home directory for the executing user.
|
||||
//
|
||||
// This uses an OS-specific method for discovering the home directory.
|
||||
// An error is returned if a home directory cannot be detected.
|
||||
public static String home()
|
||||
{
|
||||
return System.getProperty("user.home");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件是否存在
|
||||
* @param path 特定文件路径
|
||||
* @return 判断结果
|
||||
*/
|
||||
public static boolean pathExists(String path){
|
||||
File file = new File(path);
|
||||
return file.exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package minsecurity.identity.persist.sqlite.db;
|
||||
|
||||
public class Db {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package minsecurity.identity.persist.sqlite.db;
|
||||
|
||||
public class Internal {
|
||||
}
|
||||
Reference in new issue
Block a user