5

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.

Betaver
  • 51
  • 1
  • 3
  • Does it have any ODBC driver? –  Apr 19 '14 at 13:55
  • I think It also doesn't have ODBC driver – Betaver Apr 19 '14 at 14:01
  • So does it have a native c/c++ library? you may have a native(x) app to connect to the context with, then invoke the x from java app using JNA or JNI or CORBA. –  Apr 19 '14 at 16:36
  • 1
    There isn't a public JDBC driver for SQLCipher at this time. If you have a commercial requirement for a JDBC driver, please drop us a note at support@zetetic.net and we can discuss. – Stephen Lombardo Apr 21 '14 at 21:09

2 Answers2

3

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);
    }
}
simpleuser
  • 1,617
  • 25
  • 36
0

There is a fork of the JDBC driver for SQLite that modifies it to work with SQLCipher: sqlcipher-jdbc on GitHub. You have to build it yourself, though.

When you built it, you get an JAR file that you have to provide in your project's classpath.

kllmnn
  • 111
  • 1
  • 3