First of all my operating system is Ubuntu 14.04 , and I use NetBeans IDE 8.0.1 for java programing. I want to build a simple application to access a database file and because I need a serverless driver I downloaded sqlite-JDBC-3.8.7.jar and added it to the Libraries folder in my project as a new Library. After that I get a simple code to test the driver which is:
import java.sql.*;
public class test
{
public static void main( String args[] )
{
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Opened database successfully");
}
}
which must create a new database called test.db and print "Opened database successfully" but an error occurred and the exception message was :
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 foodchooser.test.main(test.java:13)
Java Result: 1
And the problem is not only in this test code but wherever i use :
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:--WhateverPath--");
In other word i am not able to use sqlite. PLZ HELP!! and thanks in advance.
Aucun commentaire:
Enregistrer un commentaire