SQLite and JDBC: Returns UnsatisfiedLinkError
I am running Xubuntu in VirtualBox. I installed sqlite3, which for some reason does not come bundled. 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 am getting 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 am getting the same error when I try to connect to an existing DB, replacing "test.db" with the full path to the file. Any ideas why?
+3
source to share
2 answers
The driver version 3.8.7 has a bug in xerial error tracking . A quick (and working) solution is to use driver version 3.8.6 until this bug is fixed.
Update: Bug fixed since 3.8.10.2 (see new bug tracker on Github ), I confirm it works now.
+5
source to share
Version 3.8.11.2 runs on Ubuntu 14 (I tested it on x86) and can be downloaded from: https://bitbucket.org/xerial/sqlite-jdbc/downloads
+4
source to share