Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite and JDBC: returns UnsatisfiedLinkError

Tags:

java

sqlite

jdbc

I am running Xubuntu in VirtualBox. I installed sqlite3 which for some reason does not come bundled any more. I added sqlite-jdbc-3.8.7.jar to my build path and run this simple code to test it.

import java.sql.*;
public class JDBC_test {

    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("org.sqlite.JDBC");  
        Connection connection = DriverManager.getConnection("jdbc:sqlite:test.db");
        connection.close();
    }
}

I get this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open(Ljava/lang/String;I)V
    at org.sqlite.core.NativeDB._open(Native Method)
    at org.sqlite.core.DB.open(DB.java:161)
    at org.sqlite.core.CoreConnection.open(CoreConnection.java:145)
    at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:66)
    at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:21)
    at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:23)
    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(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:233)
    at JDBC_test.main(JDBC_test.java:7)

I get the same error when I try to connect to an existing DB by substituting "test.db" with the full path to the file. Any ideas why?

like image 852
rwms Avatar asked Nov 23 '25 02:11

rwms


1 Answers

There is a bug in driver version 3.8.7 in xerial's bug tracker. The quick (and working) solution is to use driver version 3.8.6 until that bug will be fixed.

Update: the bug was fixed since version 3.8.10.2 (see new bug tracker on Github), I confirm that it works now.

like image 143
Sergio Avatar answered Nov 25 '25 15:11

Sergio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!