Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

Or any other free solution on encrypted SQLite beside using SQLCipher? I'm using JavaSE.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
555 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

Click on the 'Releases' tab in the center to download a pre-build .jar file.

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);
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...