mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-17 23:00:24 +08:00
fix: bugs in Sqlite
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user