Coder Social home page Coder Social logo

willena / sqlite-jdbc-crypt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xerial/sqlite-jdbc

168.0 13.0 33.0 445.05 MB

SQLite JDBC Driver with encryption support

License: Apache License 2.0

Makefile 0.80% Shell 6.63% C++ 13.50% C 7.15% Java 71.92%
sqlite3 sqlite-database jdbc-driver jdbc jdbc-connector java cross-platform encryption password pragma sqlitemc multi-cipher aes chacha20 sqlcipher

sqlite-jdbc-crypt's Introduction

SQLite JDBC Driver

GitHub Workflow Status (branch) Maven Central javadoc Sonatype Nexus (Snapshots)

SQLite JDBC is a library for accessing and creating SQLite database files in Java.

This particular fork uses another native library that provides an implementation of SEE. the native library is provided by [Utelle](http://github.com/utelle) as part of the [SQLite3MultipleCiphers](https://github.com/utelle/SQLite3MultipleCiphers) project

Our SQLiteJDBC library requires no configuration since native libraries for major OSs, including Windows, macOS, Linux etc., are assembled into a single JAR (Java Archive) file.

Project Status

The project is maintained, but is not being actively developed:

  • We follow every new version of SQLite and will release a corresponding version of our driver.

  • Bugs will be investigated, and fixed if possible.

  • New features are driven by pull requests.

Usage

➡️ More usage examples and configuration are available in USAGE.md

SQLite JDBC is a library for accessing SQLite databases through the JDBC API. For the general usage of JDBC, see JDBC Tutorial or Oracle JDBC Documentation.

  1. Download sqlite-jdbc-3.46.0.1.jar then append this jar file into your classpath.

  2. Download slf4j-api-1.7.36.jar then append this jar file into your classpath.

  3. Open a SQLite database connection from your code. (see the example below)

Example usage

Assuming sqlite-jdbc-3.46.0.1.jar and slf4j-api-1.7.36.jar are placed in the current directory.

> javac Sample.java
> java -classpath ".;sqlite-jdbc-3.46.0.1.jar;slf4j-api-1.7.36.jar" Sample   # in Windows
or
> java -classpath ".:sqlite-jdbc-3.46.0.1.jar:slf4j-api-1.7.36.jar" Sample   # in macOS or Linux
name = leo
id = 1
name = yui
id = 2

Sample.java

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;

    public class Sample
    {
      public static void main(String[] args)
      {
        // NOTE: Connection and Statement are AutoCloseable.
        //       Don't forget to close them both in order to avoid leaks.
        try
        (
          // create a database connection
          Connection connection = DriverManager.getConnection("jdbc:sqlite:sample.db");
          Statement statement = connection.createStatement();
        )
        {
          statement.setQueryTimeout(30);  // set timeout to 30 sec.

          statement.executeUpdate("drop table if exists person");
          statement.executeUpdate("create table person (id integer, name string)");
          statement.executeUpdate("insert into person values(1, 'leo')");
          statement.executeUpdate("insert into person values(2, 'yui')");
          ResultSet rs = statement.executeQuery("select * from person");
          while(rs.next())
          {
            // read the result set
            System.out.println("name = " + rs.getString("name"));
            System.out.println("id = " + rs.getInt("id"));
          }
        }
        catch(SQLException e)
        {
          // if the error message is "out of memory",
          // it probably means no database file is found
          e.printStackTrace(System.err);
        }
      }
    }

How does SQLiteJDBC work?

Our SQLite JDBC driver package (i.e., sqlite-jdbc-3.46.0.1.jar) contains three types of native SQLite libraries (sqlitejdbc.dll, sqlitejdbc.dylib, sqlitejdbc.so), each of them is compiled for Windows, macOS and Linux. An appropriate native library file is automatically extracted into your OS’s temporary folder, when your program loads org.sqlite.JDBC driver.

Supported Operating Systems

Since sqlite-jdbc-3.6.19, the natively compiled SQLite engines will be used for the following operating systems:

x86 x86_64 armv5 armv6 armv7 arm64 ppc64 riscv64

Windows

macOS

Linux (libc)

Linux (musl)

Android

FreeBSD

In the other OSs not listed above, the pure-java SQLite is used. (Applies to versions before 3.7.15)

If you want to use the native library for your OS, build the source from scratch.

GraalVM native-image support

Sqlite JDBC supports GraalVM native-image out of the box starting from version 3.40.1.0. There has been rudimentary support for some versions before that, but this was not actively tested by the CI.

By default, the sqlitejdbc library for the compilation target will be included in the native image, accompanied by the required JNI configuration. At runtime, this library will be extracted to the temp folder and loaded from there. For faster startup however, it is recommended to set the org.sqlite.lib.exportPath property at build-time. This will export the sqlitejdbc library at build-time to the specified directory, and the library will not be included as a resource. As a result, the native image itself will be slightly smaller and the overhead of exporting the library at run-time is eliminated, but you need to make sure the library can be found at run-time. The best way to do this is to simply place the library next to the executable.

CLI example

native-image -Dorg.sqlite.lib.exportPath=~/outDir -H:Path=~/outDir -cp foo.jar org.example.Main

This will place both the sqlitejdbc shared library and the native-image output in the ~/outDir folder.

Maven example

This example uses the native-build-tools maven plugin:

<plugin>
    <groupId>org.graalvm.buildtools</groupId>
    <artifactId>native-maven-plugin</artifactId>
    <configuration>
        <buildArgs>
            <buildArg>-Dorg.sqlite.lib.exportPath=${project.build.directory}</buildArg>
        </buildArgs>
    </configuration>
</plugin>

This will automatically place the sqlitejdbc library in the /target folder of your project, creating a functional execution environment. When packaging the resulting app, simply include the library in the distribution bundle.

Download

Download from Maven Central or from the releases page.

<dependencies>
    <dependency>
      <groupId>io.github.willena</groupId>
      <artifactId>sqlite-jdbc</artifactId>
      <version>3.46.0.1</version>
    </dependency>
</dependencies>

Snapshots of the development version are available in Sonatype’s snapshots repository.

Validating downloads

Maven Central resources are signed using GPG and the signature files, ending in .asc, are available in the same location as the other downloads.

The following key is currently used to sign releases:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: C1CB A75E C9BD 0BAF 8061  9354 59E0 5CE6 1818 7ED4
Comment: Taro L. Saito (For GitHub Actions) <[email protected]>

xjMEYuRVGhYJKwYBBAHaRw8BAQdA2Dp4m1Yhtb1g94pQzzL24FuP6b9KXF8lP9Dh
hZnynhfNM1Rhcm8gTC4gU2FpdG8gKEZvciBHaXRIdWIgQWN0aW9ucykgPGxlb0B4
ZXJpYWwub3JnPsKUBBMWCgA8FiEEwcunXsm9C6+AYZNUWeBc5hgYftQFAmLkVRoC
GwMFCwkIBwIDIgIBBhUKCQgLAgQWAgMBAh4HAheAAAoJEFngXOYYGH7UfPwBAK7x
TVRebZeWcAwmGaMUsbg7SgJou8xnkhByObPLUC/4AQDPsZeYmi4KXyXPzmqhCicd
Y+ZSJWIDQqitK2ujPDFXA844BGLkVRoSCisGAQQBl1UBBQEBB0Atu9kejBi+6wfO
T0a9z/LYEEdNXM/VX6xt1onKToPPdQMBCAfCeAQYFgoAIBYhBMHLp17JvQuvgGGT
VFngXOYYGH7UBQJi5FUaAhsMAAoJEFngXOYYGH7UlMABAKyRCazhVyUFg5FOpAnm
ckBY38CaMGPPLXVyY8Kr6dYFAP9wYLu7nsDZCOXkAgS+et4Pk1WZCggoYUkxsX1o
0KZXBQ==
=Wyas
-----END PGP PUBLIC KEY BLOCK-----

Project versioning explained

The project’s version follows the version of the SQLite library that is bundled in the jar, with an extra digit to denote the project’s increment.

For example, if the SQLite version is 3.39.2, the project version will be 3.39.2.x, where x starts at 0, and increments with every release that is not changing the SQLite version.

If the SQLite version is updated to 3.40.0, the project version will be updated to 3.40.0.0.

Hint for maven-shade-plugin

You may need to add shade plugin transformer to solve No suitable driver found for jdbc:sqlite: issue.

<transformer
	implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
	<resource>META-INF/services/java.sql.Driver</resource>
</transformer>
<dependency>
    <groupId>io.github.willena</groupId>
    <artifactId>sqlite-jdbc</artifactId>
    <version>3.46.0.1</version>
</dependency>

How can I help?

We are always looking for:

  • Reviewers for issues or PRs, you can check GitHub labels

  • Contributors to submit PRs, you can check GitHub labels and GitHub labels

Please read our contribution guide.

sqlite-jdbc-crypt's People

Contributors

andyjefferson avatar chris-sp365 avatar dependabot[bot] avatar doe300 avatar fatalmind avatar gbatumbya avatar gitblit avatar github-actions[bot] avatar gotson avatar jberkel avatar jcgay avatar joelcarranza avatar joshimoo avatar kares avatar kkriske avatar kroggen avatar michael-o avatar mkauf avatar pyckle avatar reftel avatar snago avatar sualeh avatar tildedave avatar trohwer avatar willena avatar witmoca avatar woehrl01 avatar xerial avatar yuvalp-k2view avatar zachee54 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sqlite-jdbc-crypt's Issues

Add Java JDBC tests for sqlite3-wx-see features

For the moment, only tests from xerial/sqlite-jdbc are ran at compile time. It could be a good thing to add some tests to check that features that come with Willena/sqlite3-wx-see are usable after compiling.

I am thinking about 2 set of tests:

  • One for the auth system.
  • One for the encryption system.
  • (optional) One for both ?

I'm open to suggestions and pull requests.
I don't think I'll do that soon since it is not realy important.

library "libsqlitejdbc.so" not found on Android

Describe the bug
Run on android platform will issue this bug

To Reproduce
public void processSqlite() {
Connection connection = null;
try
{
AssetsDatabaseManager mg = AssetsDatabaseManager.getManager();
String dbPath = mg.getDatabasePath("20220908_R0777777.db");
// getResources().openRawResource();
// Resources resources.openRawResource(resourceRawFilename)
SQLiteMCWxAES128Config config = new SQLiteMCWxAES128Config();
//connection=config.withKey("123456").build().createConnection("jdbc:sqlite:file:20220908_R0777777.db");
connection=config.withKey("123456").build().createConnection("jdbc:sqlite:file:" + dbPath);

        Statement statement = connection.createStatement();
        statement.setQueryTimeout(10);  // set timeout to 10 sec.

        ResultSet rs = statement.executeQuery("select * from data");
        while(rs.next())
        {
            // read the result set
            System.out.println("serial = " + rs.getString("serial"));
            System.out.println("id = " + rs.getInt("id"));
        }
    }
    catch(SQLException e)
    {
        // if the error message is "out of memory",
        // it probably means no database file is found
        System.err.println(e.getMessage());
        e.printStackTrace();
    }
    catch(Exception e) {
        e.printStackTrace();
    }
    finally
    {
        try
        {
            if(connection != null)
                connection.close();
        }
        catch(SQLException e)
        {
            // connection close failed.
            System.err.println(e.getMessage());
        }
    }
}

Expected behavior
A clear and concise description of what you expected to happen.

Logs
2022-10-12 11:27:01.122 16877-16877/com.somnics.sqlite E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.somnics.sqlite, PID: 16877
java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqlitejdbc.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
at java.lang.Runtime.loadLibrary0(Runtime.java:998)
at java.lang.System.loadLibrary(System.java:1656)
at org.sqlite.core.NativeDB.(NativeDB.java:40)
at org.sqlite.core.NativeDB.load(NativeDB.java:60)
at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:281)
at org.sqlite.SQLiteConnection.(SQLiteConnection.java:68)
at org.sqlite.jdbc3.JDBC3Connection.(JDBC3Connection.java:28)
at org.sqlite.jdbc4.JDBC4Connection.(JDBC4Connection.java:19)
at org.sqlite.JDBC.createConnection(JDBC.java:104)
at org.sqlite.SQLiteConfig.createConnection(SQLiteConfig.java:108)

Environment (please complete the following information):

  • OS: [Android 12]
  • CPU architecture: [armeabi]
  • sqlite-jdbc version [3.39.3.0]

Additional context
Add any other context about the problem here.

thanks.

Cipher configuration over JDBC URL doesn't work with 3.33.0

I updated my application from io.github.willena:sqlite-jdbc version 3.31.1 to 3.33.0 and noticed that encrypted databases can't be opened and newly created databases are not encrypted when I use the cipher and key configuration over the JDBC URL.

I use the cipher chacha20 and a password to open the DB connection like this:
Connection conn = DriverManager.getConnection("jdbc:sqlite:file:mydatabase.sqlite?cipher=chacha20&key=mykey");

Release 3.35.0

Since the build works now (Thanks to all, especially @Willena of course) the world may benefit from the new 3.35 release. One new thing is support for "ALTER TABLE DROP COLUMN" which is very hard to work around.

Cannot open existing encrypted database for SqlCipher v4

@Willena hi, I am very sorry to reply you so late, because your issue#25 has been closed, I can only create a new one to illustrate my results. I tested v3.35.0, v3.34.1, v3.34.0 3 versions using "SQLiteMCSqlCipherConfig.getV4Defaults();" and "SQLiteMCSqlCipherConfig.getV3Defaults();" this API, the result is that I found that these 3 versions can only be used in SqlCipher v3 is valid, v4 is confirmed not to work very well

import org.sqlite.mc.SQLiteMCSqlCipherConfig;

import java.sql.*;

public class TestSQLite {

public static void main(String[] args)
{
    Connection connection = null;
    Statement statement = null;
    try
    {
       // SQLiteMCSqlCipherConfig sqlite = SQLiteMCSqlCipherConfig.getV3Defaults();
       //connection = sqlite.withKey("accsssxd").createConnection("jdbc:sqlite:file:D:\\UserData\\Desktop\\mayan_v3.db");

        SQLiteMCSqlCipherConfig sqlite = SQLiteMCSqlCipherConfig.getV4Defaults();
        connection = sqlite.withKey("accsssxd").createConnection("jdbc:sqlite:file:D:\\UserData\\Desktop\\mayan_v4.db");


        statement = connection.createStatement();
        statement.setQueryTimeout(30);  // set timeout to 30 sec.

        ResultSet rs = statement.executeQuery("SELECT * from account ");
        while(rs.next())
        {
            // read the result set
            System.out.println("id = " + rs.getInt("id") + "    name = " + rs.getString("name"));
        }
    }
    catch(SQLException e)
    {
        // print the error log
        e.printStackTrace();
    }
    finally
    {
        try
        {
            if(statement != null) statement.close();
            if(connection != null) connection.close();
        }
        catch(SQLException e)
        {
            // connection close failed.
            e.printStackTrace();
        }
    }
}

}

The test database is as follows

sqlite.zip

#25 (comment)

Cannot open existing encrypted database

I have an encrypted SQLite database file written by another software that I want to read using this library. I know that my key is correct and that the file is valid because I can open it using DB Browser for SQLite. It is encrypted using SQLCipher 4 defaults and the key is 402fd482c38817c35ffa8ffb8c7d93143b749e7d315df7a81732a1ff43608497 (use passphrase mode in sqlite browser).

I tried opening it with this library using the following code:

String key = "402fd482c38817c35ffa8ffb8c7d93143b749e7d315df7a81732a1ff43608497";
String filePath = "/path/to/master.db";

String jdbcUrl = String.format("jdbc:sqlite:file:%s", filePath);

SQLiteMCConfig config = SQLiteMCSqlCipherConfig.getV4Defaults().withKey(key);

try (Connection connection = config.createConnection(jdbcUrl)) {
    System.out.println("Success!!");
}

But I keep getting:

org.sqlite.SQLiteException: [SQLITE_NOTADB]  File opened that is not a database file (file is not a database)
        at org.sqlite.core.DB.newSQLException(DB.java:1012) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.core.DB.newSQLException(DB.java:1024) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.core.DB.throwex(DB.java:989) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.core.NativeDB.prepare_utf8(Native Method) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.core.NativeDB.prepare(NativeDB.java:130) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.core.DB.prepare(DB.java:257) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.jdbc3.JDBC3Statement.execute(JDBC3Statement.java:45) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.SQLiteConfig.apply(SQLiteConfig.java:237) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:65) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:28) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:21) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.JDBC.createConnection(JDBC.java:115) ~[sqlite-jdbc-3.33.0.1.jar:na]
        at org.sqlite.SQLiteConfig.createConnection(SQLiteConfig.java:102) ~[sqlite-jdbc-3.33.0.1.jar:na]

I have uploaded the database file in question so you can test and recreate the scenario for yourself:
https://drive.google.com/file/d/1i-4lhdDDyUdDQ_pVvXpM2tfpaxH3SPhL/view?usp=sharing

Any help would be highly appreciated! :-)

Prompting for password

https://github.com/Willena/sqlite-jdbc-crypt#open-an-encrypted-db describes the opening of encrypted database a little bit the following way:

    Open the database file
    set cipher configuration
    Apply the corresponding key using the PRAGMA syntax
    Use normally

I have case where the database is not always encrypted and the user would be prompted for a password only when needed. What is the expected usage to detect the encryption since general SQLiteException could mean the file is otherwise faulty?

SQLite Browser?

Thanks for releasing this.

Are there any SQLite browsers than can read the encryption created by this library? I've tried both https://sqlitebrowser.org/ and https://sqlitestudio.pl both of which claim SQCipher support, but neither can open the file when provided with the password, and using a simple password like "password".

I'm creating the file (which does appear to be encrypted) with:

DriverManager.getConnection("jdbc:sqlite:db.sqlite", "", "password")

Whats the right sintax for use your library?

I was looking for a driver like this and I was trying to use it but I'm not sure if I'm right in my way. I try to do this and it looks like encrypted if I try to dump it, but I don't know if I'm using the right encryption when I try. This is my code:

`public class Conection {

private static Connection con = null;
private PreparedStatement ps = null;

public static Connection getConnection() {
    try {
        Class.forName("org.sqlite.JDBC");
        con = DriverManager.getConnection("jdbc:sqlite:test.db","sqlcipher","password");
        // System.out.println("Connected");

    } catch (SQLException | ClassNotFoundException ex) {
        Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
    }
    return con;
}

}`

is this right? It's using sqlcipher? I'm asking this, cause I'm trying to open this from console and using pragma key with sqlcipher, but I can't dump the data anyway, always cipher.

I have tested not using the password part and when I run the program the data can't be readed.

Thank you for your answer and sorry if this is not the right place for this.

Build 3.39.0

Hi,

is there a specific reason not to upgrade to 3.38.2? It seems the last one is 3.38.1 and no 3.38.x version was pushed to maven central.

Looking forward to the current version. And for the version currently in development which contains optimizations to be even faster.

Regards

Chris

jnilib files aren't signed for mac

I'm trying to notarize a Mac Desktop application that' uses this library. The new Big Sur OS has strict requirements around signing and notarization. When I'm notarizing the application, here is the error that I get from Apple with the notarization process concerning libsqlitejdbc.jnilib:

{
severity: "error",
code: null,
path: "My_App-1.0.0.dmg/My App.app/Contents/app/sqlite-jdbc-3.34.1-371b212b7663f42133e45d49e82ad30.jar/org/sqlite/native/Mac/x86_64/libsqlitejdbc.jnilib",
message: "The binary is not signed.",
docUrl: null,
architecture: "x86_64"
},
{
severity: "error",
code: null,
path: "My_App-1.0.0.dmg/My App.app/Contents/app/sqlite-jdbc-3.34.1-371b212b7663f42133e45d49e82ad30.jar/org/sqlite/native/Mac/x86_64/libsqlitejdbc.jnilib",
message: "The signature does not include a secure timestamp.",
docUrl: null,
architecture: "x86_64"
}

SQL Interface not used even if specified to

While working on #25, I discovered a new bug.

The config builder expose a method to use the sql interface instead of the more traditional pragma statements. It turns out that even if set to true pragma statements are always used. This is due to the fact that the inner JDBC classes only works with Properties object which does not contain the 'useSQLInterface' property. As a result the default mode is used (pragma mode)

URI Parameters not working in 3.33.0

Hi,

I tried to upgrade to 3.33.0 but unfortunately using URI parameters does not work for me.

According to:

this should work:

file:databasefile?cipher=sqlcipher&legacy=1&kdf_iter=4000&key=mykey

but the resulting db is not encrypted.

I tested with 3.31.1 and it worked without problems. Since the new MC lib page also does mention the URI parameters:

I don't think the feature was removed but maybe I did a mistake?

Thank you

Using jar with DBeaver

Hello,
I am trying to set your jdbc as a new driver for DBeaver in order to open an sqlcipher encrypted database.(SQLCipher v4)
I manage to configure the new driver, and set the default:cipher for the connection
When setting the key, the answer is 'Ok'
But then when executing a query on the database, the system still say that he cannot open the database because it is encrypted.

Do you have any idea of a workaround?
Thank you

java.lang.UnsatisfiedLinkError on Android

Hi,

I'm about to move from sqldroid to your library, as I want to use encrypted files in an Android App.
When I open an connection with the code snippet you provided I get the following exception:

java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqlitejdbc.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at org.sqlite.core.NativeDB.<clinit>(NativeDB.java:34) at org.sqlite.core.NativeDB.load(NativeDB.java:54) at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:256) at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:62) at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:23) at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:19) at org.sqlite.JDBC.createConnection(JDBC.java:104) at org.sqlite.JDBC.connect(JDBC.java:77) at java.sql.DriverManager.getConnection(DriverManager.java:580) at java.sql.DriverManager.getConnection(DriverManager.java:236)

Line where I open the connection:
this.connection = DriverManager.getConnection("jdbc:sqlite:"+path);

Line from my build.gradle:
implementation 'io.github.willena:sqlite-jdbc:3.37.2'

Am I doing anything wrong? The same line of code works fine, when in "desktop"-java
Thanks for your help

Doesn't open SQLCİpherV4 db files

DB files encrypted with SqlCipher V3 can be opened successfully. However, V4 encrpyted files can not be opened. The following error is produced: File opened that is not a database file (file is not a database)

SQLiteMCSqlCipherConfig.getV3Defaults().withKey(Constants.DB_CIPHER).createConnection(url) opens V3 db files.
SQLiteMCSqlCipherConfig.getV4Defaults().withKey(Constants.DB_CIPHER).createConnection(url) doesn't open V4 db files.

Database driver not available in ClassPath org.sqlite.JDBC

I am trying to use this library with in our proprietary vendors solution - which is Java based healthcare integration engine. My connection works when I use the official JDBC driver

following is my connection setting - Windows

driver class name : org.sqlite.JDBC
JDBC url jdbc:sqlite:C:\SQLITE\test1.db

I get the error Database driver not available in ClassPath org.sqlite.JDBC

I do see that in java.sqlDriver file that driver class is org.sqlite.JDBC

Please let me know if you have any feedback

Created database is not encrypted

Hi.
I use your library to create encrypted embedded database.
I added dependency using maven:

        <dependency>
            <groupId>io.github.willena</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.31.1</version>
        </dependency>

But when I create a database file:

String url = "jdbc:sqlite:file:C:/Bin/db/sqllite_crypto/database?cipher=chacha20&key=myEncryptionKey";
String user = "user";
String password = "password";
final Connection connection = DriverManager.
        getConnection(url, user, password);

the database is created, but it's not encrypted (I'm able to find inserted data using a notepad). What I do wrong? Thanks.

Anything special to use this?

Do I need to do anything to get the encryption? Configure it? Readme doesn't have any instruction (looks like a copy from the original).

linux-android-arm build errors

An issue to track some encountered errors when trying to make sqlite3-wx-see for linux-android-arm target.

With libsqlite3-wx-see at commit : Willena/libsqlite3-wx-see@ff0fed4

Here is the log from travis. Will try to investigate...
The full log file is available at: https://travis-ci.org/Willena/sqlite-jdbc-crypt/jobs/345677456

./docker/dockcross-android-arm -a --rm bash -c 'make clean-native native CROSS_PREFIX=/usr/arm-linux-androideabi/bin/arm-linux-androideabi- OS_NAME=Linux OS_ARCH=android-arm'
Unable to find image 'dockcross/android-arm:latest' locally
latest: Pulling from dockcross/android-arm
Digest: sha256:476cfe4bd9060a0c9c235e9c69df9135063622ed7876237ad5175a095bc0ff27
Status: Downloaded newer image for dockcross/android-arm:latest
Makefile.common:5: Set JAVA_HOME environment variable
rm -rf target/sqlite-3.22.0-Linux-android-arm
if [ ! -d "target/3.22.0" ] ; then git clone -b "3.22.0" https://github.com/Willena/libsqlite3-wx-see.git target/3.22.0; fi
if [ -d "target/3.22.0/src" ] ; then mv target/3.22.0/src target/sqlite-amalgamation-3220000;fi
touch target/sqlite-unpack.log
cp target/sqlite-amalgamation-3220000/* target/sqlite-3.22.0-Linux-android-arm/
#cp target/sqlite-amalgamation-3220000/sqlite3secure.c target/sqlite-3.22.0-Linux-android-arm/sqlite3secure.c
#cp target/sqlite-amalgamation-3220000/sqlite3.c target/sqlite-3.22.0-Linux-android-arm/sqlite3.c
/usr/arm-linux-androideabi/bin/arm-linux-androideabi-gcc -o target/sqlite-3.22.0-Linux-android-arm/sqlite3.o -c -Itarget/sqlite-3.22.0-Linux-android-arm -Itarget/sqlite-amalgamation-3220000 -I/include -Ilib/inc_linux -I/usr/arm-linux-androideabi/sysroot/usr/include -O2 -fPIC -fvisibility=hidden -fPIE -pie -lm -lc -landroid -ldl -llog \
			-DNDEBUG \
			-DTHREADSAFE=1 \
			-DSQLITE_MAX_ATTACHED=10 \
			-DSQLITE_SOUNDEX \
			-DSQLITE_ENABLE_COLUMN_METADATA \
			-DSQLITE_HAS_CODEC=1 \
			-DSQLITE_SECURE_DELETE \
			-DSQLITE_ENABLE_FTS3 \
			-DSQLITE_ENABLE_FTS3_PARENTHESIS \
			-DSQLITE_ENABLE_FTS4 \
			-DSQLITE_ENABLE_FTS5 \
			-DSQLITE_ENABLE_JSON1 \
			-DSQLITE_ENABLE_RTREE \
			-DSQLITE_CORE \
			-DSQLITE_ENABLE_EXTFUNC \
			-DSQLITE_ENABLE_CSV \
			-DSQLITE_ENABLE_SHA3 \
			-DSQLITE_ENABLE_CARRAY \
			-DSQLITE_ENABLE_SERIES \
			-DSQLITE_USE_URI \
			-DSQLITE_USER_AUTHENTICATION \
			-DCODEC_TYPE=CODEC_TYPE_AES256 \
     \
    target/sqlite-3.22.0-Linux-android-arm/sqlite3secure.c
In file included from /usr/arm-linux-androideabi/sysroot/usr/include/sys/ioctl.h:34:0,
                 from target/sqlite-3.22.0-Linux-android-arm/sqlite3.c:30639,
                 from target/sqlite-3.22.0-Linux-android-arm/sqlite3secure.c:31:
target/sqlite-3.22.0-Linux-android-arm/shathree.c: In function 'KeccakF1600Step':
target/sqlite-3.22.0-Linux-android-arm/shathree.c:81:7: error: expected identifier or '(' before numeric constant
   u64 B0, B1, B2, B3, B4;
       ^
In file included from target/sqlite-3.22.0-Linux-android-arm/sqlite3secure.c:102:0:
target/sqlite-3.22.0-Linux-android-arm/shathree.c:137:8: error: lvalue required as left operand of assignment
     B0 = (A00^D0);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:138:5: error: 'B1' undeclared (first use in this function)
     B1 = ROL64((A11^D1), 44);
     ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:138:5: note: each undeclared identifier is reported only once for each function it appears in
target/sqlite-3.22.0-Linux-android-arm/shathree.c:139:5: error: 'B2' undeclared (first use in this function)
     B2 = ROL64((A22^D2), 43);
     ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:140:5: error: 'B3' undeclared (first use in this function)
     B3 = ROL64((A33^D3), 21);
     ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:141:5: error: 'B4' undeclared (first use in this function)
     B4 = ROL64((A44^D4), 14);
     ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:152:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A03^D3), 28);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:161:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A01^D1), 1);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:175:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A04^D4), 27);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:184:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A02^D2), 62);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:204:8: error: lvalue required as left operand of assignment
     B0 = (A00^D0);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:219:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A33^D3), 28);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:228:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A11^D1), 1);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:242:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A44^D4), 27);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:251:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A22^D2), 62);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:271:8: error: lvalue required as left operand of assignment
     B0 = (A00^D0);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:286:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A43^D3), 28);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:295:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A31^D1), 1);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:309:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A24^D4), 27);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:318:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A12^D2), 62);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:338:8: error: lvalue required as left operand of assignment
     B0 = (A00^D0);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:353:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A13^D3), 28);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:362:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A21^D1), 1);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:376:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A34^D4), 27);
        ^
target/sqlite-3.22.0-Linux-android-arm/shathree.c:385:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A42^D2), 62);
        ^
make: *** [target/sqlite-3.22.0-Linux-android-arm/sqlite3.o] Error 1
Makefile:50: recipe for target 'target/sqlite-3.22.0-Linux-android-arm/sqlite3.o' failed
make: *** [linux-android-arm] Error 2

unable to open the database using sqlcipher

created an encrypted database

...

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

...

then tried to open the database from the command line using sqlcipher

SQLCipher version 3.15.2 2016-11-28 19:13:37
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> PRAGMA key='apassword';
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
/**** ERROR: (26) file is encrypted or is not a database *****/
ROLLBACK; -- due to errors
sqlite>

SQLiteMCConfig.Builder()#withHexKey and rekey compatibility

Can't understand how the hex key methods withHexKey(String) and withHexKey(byte[]) works.

Sample code for understanding variables:

SQLiteMCSqlCipherConfig dbConfigBuilder = SQLiteMCSqlCipherConfig.getDefault();
dbConfigBuilder.withKey("x'0a0a'");
SQLiteMCConfig dbConfig = dbConfigBuilder.build();
connection = dbConfig.createConnection(dbURL);

Expected behavior:

  1. Using method dbConfigBuilder.withKey("x'0a0a'") works normally and statement PRAGMA rekey = "x'0f0f'" compatible.

  2. Setting pragma dbConfig.setPragma(SQLiteConfig.Pragma.HEXKEY_MODE, String.valueOf(SQLiteConfig.HexKeyMode.SQLCIPHER)) and using withKey("0a0a'") and PRAGMA rekey = "x'0f0f'" compatible.

Unexpected behavior

  1. When i start using withHexKey(String) and rekey with syntax PRAGMA rekey = "x'0f0f'", then method dbConfigBuilder.withHexKey("0f0f") can't open database. I think this method doesn't work correctly due to hardcoded setPragma(Pragma.HEXKEY_MODE, String.valueOf(HexKeyMode.SSE)) in SQLiteMCConfig.Builder()#withHexKey(String). When i change Pragma.HEXKEY_MODE to HexKeyMode.SQLCIPHER, after dbConfigBuilder.withHexKey("0f0f"), then PRAGMA rekey compatibility fixed.

  2. When using withHexKey(byte[]) for rekey i need convert bytes with spacing (e.g.: "0F 0F") and use rekey without special syntax "x'0f0f", fully compatible PRAGMA rekey = "0F 0F". It looks like the hex string it's ordinary password for SQLite.
    And why hex string using spaces?

Backup and Restore command should take ciphers parameters

When you're trying to backup the database using the "backup to " non standard command, the destination database is opened clear all the time. If the source is encrypted you might want to keep your backup encrypted or encrypt it with another cipher algorithm. The "backup to" command should provide a way to choose the algorithm parameters like when the user opens the database.

The same thing apply for the "restore from" command.

Possible workaround ( not tested ):

You can try putting cipher parameters after the name like when you're opening the database.
Ex:

  • Backup to file:dB.db?key=AA
  • Backup to dB.db?key=AA

If that doesn't work you can still cipher it after backup using the standard way:

  • open the new database clear ( do not specify the key at the end.
  • execute the "PRAGMA key='...'" SQL query to apply a key to the database.
  • close the database

After that it should be now encrypted.

If you want to restore the database, might need to rekey the backup before restore

  • open with ciphers parameters
  • execute PRAGMA rekey=''
  • close the database
  • do the restore

Rekeying the backup might be also needed since at this stage it is clear

  • PRAGMA rekey='mykey'

Another workaround would be to:

  1. open the database
  2. dump it as sql file
  3. execute the sql file in a new database

Opening Encrypted DB in SQLite Browser?

static void newTest() throws SQLException {
System.out.println("test");
Connection connection = DriverManager.getConnection("jdbc:sqlite:file:C:/Users/Admin/.ispiro/databasenew1.db?cipher=sqlcipher&legacy=4&legacy_page_size=4096&kdf_iter=256000&fast_kdf_iter=2&hmac_use=1&hmac_pgno=1&hmac_salt_mask=0x3a&kdf_algorithm=2&hmac_algorithm=2&plaintext_header_size=0&key=oo");
Statement statement = connection.createStatement();
statement.setQueryTimeout(30);

		    statement.executeUpdate("drop table if exists person");
		    statement.executeUpdate("create table person (id integer, name string)");
		    statement.executeUpdate("insert into person values(1, 'leo')");
		    statement.executeUpdate("insert into person values(2, 'yui')");
		    connection.close();
	  }

Above example is created from your previous references however when i try to open the db file with tables in SQLite Browser 3.11.2 it gives me error. Could not open database file. Reason file is not a database

Something wrong when using username and password

When doing some tests (#14 (comment)) for another issue, a bug appeared.

In the code provided the Test1 function should have failed but in fact not. You are always able to read the database even if the provided key in URI is different.

The username is always ignored. The password will be used as key.

IT IS NOT RECOMMENDED TO USE username AND password with SQLite databases. Please use URI configuration, Pragma configuration, or use classes in the org.sqlite.mc package to create the connection.

Support JDBC date, time and timestamp escape sequences

Hi,

JDBC drivers support the JDBC Date, Time, and Timestamp escape sequences.

Thus, the following is supposed to work using JDBC drivers (sometimes with addition of "FROM DUAL"):
SELECT {d '2016-06-29'}, {ts '2016-06-29 11:07:35.123'}

Unfortunately, it is not supported by this driver. This causes compatibility issue where standard JDBC SQL fails.

Do you think you could do something about it?

(And thanks a lot for the updated project! The original Xerial one seems to be in limbo...)

NullPointerException in SQLiteConfig

In SQLiteConfig.java, Line 220

String password = pragmaTable.getProperty(Pragma.KEY.pragmaName);
password = password.isEmpty() ? pragmaTable.getProperty(Pragma.PASSWORD.pragmaName) : password;

NullPointerException here,because "password" is null.

Change the second row to
password = password==null || password.isEmpty() ? pragmaTable.getProperty(Pragma.PASSWORD.pragmaName) : password;

java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8

Windows 10, running openjdk 11 (64 bit). Running version 3.22 using AES256.

At first glance I thought it was related to xerial#351 or xerial#269... but I'm not sure for two reasons:

  1. Those issues have been closed for quite some time. I believe the fixes should be in the code already.
  2. The issues seem to be related to multithreading... This is occuring in my main method which is only being called the one time.

I cannot reproduce it--got the stack trace from a bug report.

Relevant stack trace:

java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8([BI)V
        at org.sqlite.core.NativeDB._open_utf8(NativeDB.java:-2)
        at org.sqlite.core.NativeDB._open(NativeDB.java:71)
        at org.sqlite.core.DB.open(DB.java:174)
        at org.sqlite.core.CoreConnection.open(CoreConnection.java:220)
        at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
        at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:25)
        at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
        at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
        at org.sqlite.JDBC.createConnection(JDBC.java:114)
        at org.sqlite.JDBC.connect(JDBC.java:88)
        at java.sql.DriverManager.getConnection(Unknown:-1)
        at java.sql.DriverManager.getConnection(Unknown:-1)

Any ideas? Will the newest release potentially fix this? Will you get jar's out for the newest release or do I need to build myself?

Edit: looks like there are more issues still open that could be relevant: xerial#337 and xerial#225

Support M1 Macs

Please support the new Apple M1 Macs with this library, which require Arm64 support (I believe). With the new Arm chips coming from apple, Microsoft is taking arm cpus more seriously, so it'd be nice to see support for arm architectures on windows as well.

Thanks for maintaining this library :)

v3.33.0.1: restored database can not be opened

I created a ChaCha20 encrypted sqlite database with v3.31.1 and used the restore from command with an regular sqlite database.
This encrypted sqlite database can only be opened with v3.31.1, but not with v3.33.0.1.

If I create a ChaCha20 encrypted sqlite database with some tables and data without restoring from a regular database with v3.31.1 and v3.33.0.1 and let v3.33.0.1 open the v3.31.1 database and v3.31.1 open the v3.33.0.1 database it works fine. Both versions are compatible in this case.

How can I change the password

I use below code to create a sqlite DB, and open it by sqlite studio GUI tool.
I want to know how can I change the DB password if I need?

Class.forName("org.sqlite.JDBC");
Connection c = DriverManager.getConnection("jdbc:sqlite:test.db","","123456");

Thanks!

email: [email protected]

linux-ppc64 build errors

An issue to track some encountered errors when trying to make sqlite3-wx-see for linux-android-arm target.

With libsqlite3-wx-see at commit : Willena/libsqlite3-wx-see@ff0fed4

Here is the log from travis. Will try to investigate...
The full log file is available at: https://travis-ci.org/Willena/sqlite-jdbc-crypt/jobs/345896766

./docker/dockcross-ppc64 -a --rm bash -c 'make clean-native native CROSS_PREFIX=powerpc64le-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64'
Unable to find image 'dockcross/linux-ppc64le:latest' locally
latest: Pulling from dockcross/linux-ppc64le
Status: Downloaded newer image for dockcross/linux-ppc64le:latest
Makefile.common:5: Set JAVA_HOME environment variable
rm -rf target/sqlite-3.22.0-Linux-ppc64
if [ ! -d "target/3.22.0" ] ; then git clone -b "3.22.0" https://github.com/Willena/libsqlite3-wx-see.git target/3.22.0; fi
if [ -d "target/3.22.0/src" ] ; then mv target/3.22.0/src target/sqlite-amalgamation-3220000;fi
touch target/sqlite-unpack.log
cp target/sqlite-amalgamation-3220000/* target/sqlite-3.22.0-Linux-ppc64/
#cp target/sqlite-amalgamation-3220000/sqlite3secure.c target/sqlite-3.22.0-Linux-ppc64/sqlite3secure.c
#cp target/sqlite-amalgamation-3220000/sqlite3.c target/sqlite-3.22.0-Linux-ppc64/sqlite3.c
powerpc64le-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=powerpc64le-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/powerpc64le-linux-gnu/4.9/lto-wrapper
Target: powerpc64le-linux-gnu
Configured with: ../src/configure -v --with-pkgversion=' 4.9.2-10' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,go,fortran,objc --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libsanitizer --disable-libquadmath --enable-plugin --with-system-zlib --enable-objc-gc --enable-secureplt --with-cpu=power7 --with-tune=power8 --disable-multilib --enable-multiarch --with-long-double-128 --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=powerpc64le-linux-gnu --program-prefix=powerpc64le-linux-gnu-
Thread model: posix
gcc version 4.9.2 ( 4.9.2-10) 
powerpc64le-linux-gnu-gcc -o target/sqlite-3.22.0-Linux-ppc64/sqlite3.o -c -Itarget/sqlite-3.22.0-Linux-ppc64 -Itarget/sqlite-amalgamation-3220000 -I/include -Ilib/inc_linux -O2 -fPIC -fvisibility=hidden \
			-DNDEBUG \
			-DTHREADSAFE=1 \
			-DSQLITE_MAX_ATTACHED=10 \
			-DSQLITE_SOUNDEX \
			-DSQLITE_ENABLE_COLUMN_METADATA \
			-DSQLITE_HAS_CODEC=1 \
			-DSQLITE_SECURE_DELETE \
			-DSQLITE_ENABLE_FTS3 \
			-DSQLITE_ENABLE_FTS3_PARENTHESIS \
			-DSQLITE_ENABLE_FTS4 \
			-DSQLITE_ENABLE_FTS5 \
			-DSQLITE_ENABLE_JSON1 \
			-DSQLITE_ENABLE_RTREE \
			-DSQLITE_CORE \
			-DSQLITE_ENABLE_EXTFUNC \
			-DSQLITE_ENABLE_CSV \
			-DSQLITE_ENABLE_SHA3 \
			-DSQLITE_ENABLE_CARRAY \
			-DSQLITE_ENABLE_SERIES \
			-DSQLITE_USE_URI \
			-DSQLITE_USER_AUTHENTICATION \
			-DCODEC_TYPE=CODEC_TYPE_AES256 \
     \
    target/sqlite-3.22.0-Linux-ppc64/sqlite3secure.c
In file included from /usr/include/termios.h:39:0,
                 from /usr/include/powerpc64le-linux-gnu/bits/ioctl-types.h:5,
                 from /usr/include/powerpc64le-linux-gnu/sys/ioctl.h:29,
                 from target/sqlite-3.22.0-Linux-ppc64/sqlite3.c:30639,
                 from target/sqlite-3.22.0-Linux-ppc64/sqlite3secure.c:31:
target/sqlite-3.22.0-Linux-ppc64/shathree.c: In function 'KeccakF1600Step':
target/sqlite-3.22.0-Linux-ppc64/shathree.c:81:7: error: expected identifier or '(' before numeric constant
   u64 B0, B1, B2, B3, B4;
       ^
In file included from target/sqlite-3.22.0-Linux-ppc64/sqlite3secure.c:102:0:
target/sqlite-3.22.0-Linux-ppc64/shathree.c:137:8: error: lvalue required as left operand of assignment
     B0 = (A00^D0);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:138:5: error: 'B1' undeclared (first use in this function)
     B1 = ROL64((A11^D1), 44);
     ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:138:5: note: each undeclared identifier is reported only once for each function it appears in
target/sqlite-3.22.0-Linux-ppc64/shathree.c:139:5: error: 'B2' undeclared (first use in this function)
     B2 = ROL64((A22^D2), 43);
     ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:140:5: error: 'B3' undeclared (first use in this function)
     B3 = ROL64((A33^D3), 21);
     ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:141:5: error: 'B4' undeclared (first use in this function)
     B4 = ROL64((A44^D4), 14);
     ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:152:8: error: lvalue required as left operand of assignment
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:161:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A01^D1), 1);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:175:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A04^D4), 27);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:184:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A02^D2), 62);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:204:8: error: lvalue required as left operand of assignment
     B0 = (A00^D0);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:219:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A33^D3), 28);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:228:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A11^D1), 1);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:242:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A44^D4), 27);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:251:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A22^D2), 62);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:271:8: error: lvalue required as left operand of assignment
     B0 = (A00^D0);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:286:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A43^D3), 28);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:295:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A31^D1), 1);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:309:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A24^D4), 27);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:318:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A12^D2), 62);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:338:8: error: lvalue required as left operand of assignment
     B0 = (A00^D0);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:353:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A13^D3), 28);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:362:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A21^D1), 1);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:376:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A34^D4), 27);
        ^
target/sqlite-3.22.0-Linux-ppc64/shathree.c:385:8: error: lvalue required as left operand of assignment
     B0 = ROL64((A42^D2), 62);
        ^
make: *** [target/sqlite-3.22.0-Linux-ppc64/sqlite3.o] Error 1
Makefile:50: recipe for target 'target/sqlite-3.22.0-Linux-ppc64/sqlite3.o' failed
make: *** [linux-ppc64] Error 2

Cannot delete DB file when connection failed

Hello!

I try connect to database with incorrect key (for testing) on Windows 10.

Code example:

    String dbURL = "jdbc:sqlite:file:" + dbPath + File.separator + "dbFile.db";
    SQLiteMCSqlCipherConfig dbConfig = new SQLiteMCSqlCipherConfig();
    dbConfig.enforceForeignKeys(true);
    dbConfig.setAutoVacuum(SQLiteConfig.AutoVacuum.FULL);
    Connection connection = dbConfig.withKey(key).createConnection(dbURL);

I get SQLException at the moment createConnection(String) and when I trying delete existing database file (Files.deleteIfExists(path);) then I've got FileSystemException:
java.nio.file.FileSystemException: ...\dbFile.db : The process cannot access the file because it is being used by another process.

I think that these behavior maybe fixed by closing instance of Connection, but I can't test in my app because not any connection returned in method createConnection(String).


added:
I did an experiment with debugger.
When in SQLiteConfig.class was failed
stat.execute("select 1 from sqlite_master");
and after closing "stat" object in finally block, I has executed manually by debugger tool "conn.close()".
Manually executing conn.close() has been solve problem with deleting database file.

Is it possible to expect this fix in the project?

added2:
For self-catching Exception and closing connection now I has been using the following solution

connection = DriverManager.getConnection(dbURL);
dbConfig.withKey(key).apply(connection);

Can't load '.so' files after GraalVM native image

  1. When I use sqlite-jdbc-crypt in java or Jar, it works.

  2. After I build Jar file to Native executor file with graalvm, I got the error below:

java.lang.UnsatisfiedLinkError: Can't load library: /tmp/sqlite-3.36.0-47497685-3d26-429d-9f26-9ac89d7a3e1d-libsqlitejdbc.so
Exception in thread "main" java.sql.SQLException: Error opening connection
        at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:257)
        at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:60)
        at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:23)
        at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:19)
        at org.sqlite.JDBC.createConnection(JDBC.java:104)
        at org.sqlite.SQLiteDataSource.getConnection(SQLiteDataSource.java:450)
        at org.sqlite.SQLiteDataSource.getConnection(SQLiteDataSource.java:442)
        at com.mageddo.sqlite.App.main(App.java:19)
Caused by: java.lang.Exception: No native library found for os.name=Linux, os.arch=x86_64, paths=[/org/sqlite/native/Linux/x86_64]
        at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:391)
        at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:65)
        at org.sqlite.core.NativeDB.load(NativeDB.java:56)
        at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:254)
        ... 7 more
  1. When I use System.load after graal, I get the same error.
try {
	System.load("/data/xxx/libsqlitejdbc.so");
} catch (UnsatisfiedLinkError e) {
	System.err.println(e);
}

You can change this line of the demo project to reproduce the error.
https://github.com/mageddo/graalvm-examples/blob/master/sqlite/build.gradle#L14

implementation("io.github.willena:sqlite-jdbc:3.36.0")

while implementation("org.xerial:sqlite-jdbc:3.36.0").

Do you have any idea about this question?
Thanks!

Ciphers and sqlite-jdbc-crypt

Sorry,

I had some issues for finding cipher for sqlite-jdbc-crypt. Any help? look like the latest version had changed the encryption part.
I had checked SQLite3MultipleCiphers but it only provides Win32 and Win64. There's no Mac binary.
And also, how to "plug" the cipher into sqlite-jdbc-crypt? Any example for that?

Thanks :-D

How to encrypt existing database?

Hi. Tried bunch of methods, but still can't encrypt database (database stay unencrypted after set cipher and key)

Variant 1

final SQLiteMCConfig connectionConfig = SQLiteMCWxAES128Config.getDefault().withKey("testkey");
try (Connection con = DriverManager.getConnection("jdbc:sqlite:./database.sqlite3");
	Statement statement = con.createStatement()) {
		connectionConfig.applyCipherParameters(con, statement);
}

Variant 2

try (Connection con = DriverManager.getConnection("jdbc:sqlite:./database.sqlite3");
	Statement statement = con.createStatement()) {
		statement.execute("SELECT sqlite3mc_config('cipher', 'aes128cbc');");
		statement.execute("PRAGMA key='testKey';");
}

What i'm doing wrong?

org.sqlite.util.OSInfo.isMusl(): /proc/self/map_files: Operation not permitted

I am using your library to access an encrypted sqlite database for an application I wrote, which is used in many different environments. I recently updated the library from 3.35.5.3 to 3.38.1.1 (the latest at the time), and in one particular environment there is a new issue.

Here is the relevant stack trace of the exception that is being thrown:

 org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
	at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:69)
	at org.hibernate.tool.schema.internal.exec.ImprovedExtractionContextImpl.getJdbcConnection(ImprovedExtractionContextImpl.java:60)
	at org.hibernate.tool.schema.internal.exec.ImprovedExtractionContextImpl.getJdbcDatabaseMetaData(ImprovedExtractionContextImpl.java:67)
	at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTables(InformationExtractorJdbcDatabaseMetaDataImpl.java:329)
	at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTablesInformation(DatabaseInformationImpl.java:120)
	at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:65)
	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207)
	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114)
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:313)
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
	at au.com.bluecrystal.services.SQLiteConnectionService.initConnection(SQLiteConnectionService.java:31)
	at au.com.bluecrystal.services.ConfigurationConnectionService.initConnection(ConfigurationConnectionService.java:41)
	at au.com.bluecrystal.services.ConfigurationConnectionService.initialise(ConfigurationConnectionService.java:32)
	at au.com.bluecrystal.AgentMain.startApp(AgentMain.java:82)
	at au.com.bluecrystal.AgentMain.main(AgentMain.java:163)
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
	at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:692)
	at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
	at org.hibernate.c3p0.internal.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:72)
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
	at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:43)
	... 18 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
	at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1507)
	at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:644)
	at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:554)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:758)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:685)
	at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
	at org.hibernate.c3p0.internal.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:72)
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
	at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:43)
	... 18 more
Caused by: java.sql.SQLException: Error opening connection
	at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:259)
	at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:62)
	at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:23)
	at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:19)
	at org.sqlite.JDBC.createConnection(JDBC.java:104)
	at org.sqlite.JDBC.connect(JDBC.java:77)
	at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:161)
	at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
	at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:202)
	at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)
	at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)
	at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
	at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)
	at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
Caused by: java.io.UncheckedIOException: java.nio.file.FileSystemException: /proc/self/map_files: Operation not permitted
	at java.nio.file.Files$2.hasNext(Unknown Source) ~[?:?]
	at java.util.Spliterators$IteratorSpliterator.tryAdvance(Unknown Source) ~[?:?]
	at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source) ~[?:?]
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[?:?]
	at java.util.stream.MatchOps$MatchOp.evaluateSequential(Unknown Source) ~[?:?]
	at java.util.stream.MatchOps$MatchOp.evaluateSequential(Unknown Source) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[?:?]
	at java.util.stream.ReferencePipeline.anyMatch(Unknown Source) ~[?:?]
	at org.sqlite.util.OSInfo.isMusl(OSInfo.java:127)
	at org.sqlite.util.OSInfo.translateOSNameToFolderName(OSInfo.java:226)
	at org.sqlite.util.OSInfo.getOSName(OSInfo.java:108)
	at org.sqlite.util.OSInfo.getNativeLibFolderPathForCurrentOS(OSInfo.java:104)
	at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:348)
	at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:65)
	at org.sqlite.core.NativeDB.load(NativeDB.java:56)
	at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:256)
	at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:62)
	at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:23)
	at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:19)
	at org.sqlite.JDBC.createConnection(JDBC.java:104)
	at org.sqlite.JDBC.connect(JDBC.java:77)
	at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:161)
	at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
	at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:202)
	at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)
	at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)
	at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
	at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)
	at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
Caused by: java.nio.file.FileSystemException: /proc/self/map_files: Operation not permitted
	at sun.nio.fs.UnixException.translateToIOException(Unknown Source) ~[?:?]
	at sun.nio.fs.UnixException.asIOException(Unknown Source) ~[?:?]
	at sun.nio.fs.UnixDirectoryStream$UnixDirectoryIterator.readNextEntry(Unknown Source) ~[?:?]
	at sun.nio.fs.UnixDirectoryStream$UnixDirectoryIterator.hasNext(Unknown Source) ~[?:?]
	at java.nio.file.Files$2.hasNext(Unknown Source) ~[?:?]
	at java.util.Spliterators$IteratorSpliterator.tryAdvance(Unknown Source) ~[?:?]
	at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source) ~[?:?]
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[?:?]
	at java.util.stream.MatchOps$MatchOp.evaluateSequential(Unknown Source) ~[?:?]
	at java.util.stream.MatchOps$MatchOp.evaluateSequential(Unknown Source) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[?:?]
	at java.util.stream.ReferencePipeline.anyMatch(Unknown Source) ~[?:?]
	at org.sqlite.util.OSInfo.isMusl(OSInfo.java:127)
	at org.sqlite.util.OSInfo.translateOSNameToFolderName(OSInfo.java:226)
	at org.sqlite.util.OSInfo.getOSName(OSInfo.java:108)
	at org.sqlite.util.OSInfo.getNativeLibFolderPathForCurrentOS(OSInfo.java:104)
	at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:348)
	at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:65)
	at org.sqlite.core.NativeDB.load(NativeDB.java:56)
	at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:256)
	at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:62)
	at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:23)
	at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:19)
	at org.sqlite.JDBC.createConnection(JDBC.java:104)
	at org.sqlite.JDBC.connect(JDBC.java:77)
	at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:161)
	at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
	at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:202)
	at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)
	at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)
	at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
	at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)
	at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

The user running the application does not have root access in this environment, nor is able to be given root access. The /proc/self/map_files folder has permission dr-x------ and is owned by root.

Reverting back to the older version, before the isMusl method was added, has worked in this environment.

file is not a database

I want to use SQLite-JDBC-crypt to decrypt SQLite instead of sqlcipher. I have encountered some problems. I am not sure how to solve them

sqlite> PRAGMA cipher_default_kdf_iter = 4000;
sqlite> PRAGMA key = '64846df';
ok
sqlite> PRAGMA cipher_use_hmac = OFF;
sqlite> PRAGMA cipher_page_size = 1024;
sqlite> PRAGMA cipher_compatibility = 1;
sqlite> select * from rcontact;

        Connection connection = null;
        // create a database connection
         connection = DriverManager.getConnection("jdbc:sqlite:/Users/apple/Downloads/EnMicroMsg.db? 
                                 cipher=sqlcipher&hmac_use=0&legacy=1&kdf_iter=4000
                                &legacy_page_size=1024&key=64846df&compatibility=1");
         Statement statement = connection.createStatement();
        statement.setQueryTimeout(30);  // set timeout to 30 sec.
         ResultSet rs = statement.executeQuery("select * from rcontact");

1.The use of sqlcipher is normal, and SQLite JDBC crypt decryption appears
[SQLITE_ NOTADB] File opened that is not a database file (file is not a database)
I'm not sure how to solve this problem. I hope you can help me

How to use the library on Android

I've been trying to use this library on Android and have trouble getting this to work.

Is anybody using this on Android already? Are there any resources on how to use this on Android?

Compile time options differences

Hi,

while debugging a different issue I decided to diff the original xerial compile time options to our lib.

I noticed the following:

  • xerial sets HAVE_USLEEP ( xerial#381 )
  • xerial sets SQLITE_ENABLE_STAT4 instead of DSQLITE_ENABLE_STAT2
  • xerial doesn't set SQLITE_ENABLE_EXPLAIN_COMMENTS (maybe not neccessary for apps, https://www.sqlite.org/compile.html )
  • xerial doesn't set SQLITE_MAX_ATTACHED (10 is default anyway)
  • xerial doesn't set SQLITE_SECURE_DELETE. It just slow down delete operations. Downside is that the deleted data is left in free pages but the entire db is encrypted anyway. The parameter doesn't really improve encryption
  • xerial doesn't set SQLITE_ENABLE_DESERIALIZE because it's not needed anymore ( https://www.sqlite.org/compile.html )

Of course I could file a PR but I'd like to see your comments before.

How to remove the password without sqlcipher_export?

I tried to execute sql

  • ATTACH DATABASE 'test.db' AS plaintext KEY '';
  • SELECT sqlcipher_export('plaintext');
  • DETACH DATABASE plaintext;

But i got an error

[SQLITE_ERROR] SQL error or missing database (no such function: sqlcipher_export)

So can I remove the password without sqlcipher_export function ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.