JDBC for SQLCipher [英] JDBC for SQLCipher
问题描述
是否存在用于SQLCipher的JDBC驱动程序?我想用javaSE和加密的SQLite编写程序.我在Internet上进行搜索,但在SQLCipher JDBC上发现的内容却很少.
Is there any JDBC driver exist for SQLCipher? I want to write program with javaSE and encrypted SQLite. I searched on the Internet and found nothing much on SQLCipher JDBC.
或者除了使用SQLCipher之外,还有其他关于加密SQLite的免费解决方案吗?我正在使用JavaSE.
Or any other free solution on encrypted SQLite beside using SQLCipher? I'm using JavaSE.
推荐答案
在
There is an Apache 2.0 licensed package named sqlite-jdbc-crypt
("SQLite JDBC Driver with encryption and authentication support") available at https://github.com/Willena/sqlite-jdbc-crypt
单击中心的发布"标签以下载预构建的.jar文件.
Click on the 'Releases' tab in the center to download a pre-build .jar file.
下面是示例Java代码,用于创建名为db.sql
的加密SQLite数据库,该数据库已使用密码apassword
进行了加密:
Here's example Java code to create an encrypted SQLite database named db.sql
which is encrypted with the password apassword
:
package com.name.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Test {
public static void main(final String[] args) {
try (final Connection connection = DriverManager.getConnection("jdbc:sqlite:db.sqlite", "",
"apassword")) {
try (final Statement stmt = connection.createStatement()) {
stmt.execute("CREATE TABLE test (data TEXT(10));");
stmt.execute("INSERT INTO test VALUES('hello');");
}
connection.close();
} catch (final SQLException e) {
e.printStackTrace();
}
System.out.println("finished");
System.exit(0);
}
}
这篇关于JDBC for SQLCipher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!