fix: bugs in Sqlite

This commit is contained in:
ChessNineeee
2021-05-14 12:06:29 +08:00
parent 4cc1c88ed2
commit c316017f16
2 changed files with 8 additions and 7 deletions
+1 -6
View File
@@ -251,15 +251,10 @@
<!-- Sqlite Driver compatible with sqlcipher-->
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.28.0</version>
</dependency>
<dependency>
<groupId>io.github.willena</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.35.4</version>
<version>3.35.5.1</version>
</dependency>
<!--jmh 基准测试 -->
@@ -1,9 +1,11 @@
package minsecurity.identity.persist.sqlite;
import org.sqlite.mc.SQLiteMCConfig;
import org.sqlite.mc.SQLiteMCSqlCipherConfig;
import java.io.File;
import java.sql.*;
import java.util.Properties;
/*
* @Author: zhengqi wu
@@ -80,8 +82,12 @@ public class Sqlite {
new File(db_path).mkdirs();
}
String real_db_file = db_path + db_file;
// 兼容sqlcipher
c = DriverManager.getConnection("jdbc:sqlite:" + real_db_file, SQLiteMCSqlCipherConfig.getV4Defaults().withKey(passwd2HexKey()).toProperties());
SQLiteMCSqlCipherConfig sqlCipherConfig = SQLiteMCSqlCipherConfig.getV4Defaults();
SQLiteMCConfig config = sqlCipherConfig.withKey(passwd2HexKey());
Properties properties = config.toProperties();
c = DriverManager.getConnection("jdbc:sqlite:" + real_db_file, properties);
stmt = c.createStatement();
stmt.executeUpdate(table_create);
stmt.close();