db unittest completed(annotations added to be compatible with go version's json)

This commit is contained in:
ChessNineeee committed 2021-04-07 19:34:43 +08:00
1 parent f727a5c505
commit c43a9a3a1c
7 files changed
+173 -27

No files matched your search

@@ -1,6 +1,5 @@
package minsecurity.identity.persist.sqlite;
import org.sqlite.mc.SQLiteMCConfig;
import org.sqlite.mc.SQLiteMCSqlCipherConfig;
import java.io.File;
@@ -72,15 +71,16 @@ public class Sqlite {
try{
String homePath = SqliteUtil.home();
homePath += "/min/identity/";
String dbPath = homePath;
if (!SqliteUtil.pathExists(dbPath)){
new File(dbPath).mkdirs();
db_path = homePath;
if (!SqliteUtil.pathExists(db_path)){
new File(db_path).mkdirs();
}
String real_db_file = dbPath + db_file;
String real_db_file = db_path + db_file;
// 兼容sqlcipher
c = DriverManager.getConnection("jdbc:sqlite:" + real_db_file, SQLiteMCSqlCipherConfig.getV4Defaults().withKey(passwd2HexKey()).toProperties());
stmt = c.createStatement();
stmt.executeUpdate(table_create);
int res = stmt.executeUpdate(table_create);
System.out.println(res);
stmt.close();
c.close();
}catch (Exception ex){
@@ -94,11 +94,12 @@ public class Sqlite {
Connection c = null;
Statement stmt = null;
try{
boolean db_exists = SqliteUtil.pathExists(filePath);
db_path = filePath;
boolean db_exists = SqliteUtil.pathExists(db_path);
if (!db_exists){
new File(filePath).mkdirs();
new File(db_path).mkdirs();
}
String real_db_file = filePath + db_file;
String real_db_file = db_path + db_file;
// 兼容sqlcipher
c = DriverManager.getConnection("jdbc:sqlite:" + real_db_file, SQLiteMCSqlCipherConfig.getV4Defaults().withKey(passwd2HexKey()).toProperties());
stmt = c.createStatement();
@@ -117,7 +118,7 @@ public class Sqlite {
Connection c = null;
try{
String real_db_file = db_path + db_file;
Class.forName("org.sqlite.JDBC");
// Class.forName("org.sqlite.JDBC");
// 兼容sqlcipher
c = DriverManager.getConnection("jdbc:sqlite:" + real_db_file, SQLiteMCSqlCipherConfig.getV4Defaults().withKey(passwd2HexKey()).toProperties());
// TODO 设置数据库最大连接数