JDBC for SQLCipher [英] JDBC for SQLCipher

查看:362
本文介绍了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.

推荐答案

sqlite-jdbc-crypt(具有加密和身份验证支持的SQLite JDBC驱动程序")的Apache 2.0许可包. /github.com/Willena/sqlite-jdbc-crypt"rel =" nofollow noreferrer>"> https://github.com/Willena/sqlite-jdbc-crypt

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆