Hello all!
I got this JDBC SQLite driver from http://www.zentus.com/sqlitejdbc/ It's really cool and everything works great, except that I can not manage to my class to start from the command line...
It works great with Eclipse, after adding the sqlitejdbc.jar in the project properties...
this is the class
import java.sql.*;
import java.util.*;
public class Test {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Calendar cal = Calendar.getInstance();
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");
Statement stat = conn.createStatement();
stat.executeUpdate("drop table if exists people");
stat.executeUpdate("create table people (id INTEGER PRIMARY KEY, name, occupation DEFAULT 0);");
stat.executeUpdate("insert into people (name, occupation) values ('Gandhi', 'politics');");
stat.executeUpdate("insert into people (name) values ('Turing');");
stat.executeUpdate("insert into people (name, occupation) values ('Wittgenstein', '" + cal.getTimeInMillis() + "');");
ResultSet rs = stat.executeQuery("select * from people;");
while (rs.next()) {
System.out.println("name = " + rs.getString("name"));
System.out.println("occupation = " + rs.getString("occupation"));
}
rs.close();
conn.close();
}
}
If I try to start it simply with: "java Test" I get this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no sqlitejdbc in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.sqlite.DB.<clinit>(DB.java:33)
at org.sqlite.Conn.<init>(Conn.java:10)
at org.sqlite.JDBC.connect(JDBC.java:38)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at Test.main(Test.java:11)
If I try to do as they say in the driver's website with "java -cp sqlitejdbc.jar -Djava.library.path=. Test" I get:
Exception in thread "main" java.lang.NoClassDefFoundError: Test
Any ideas? I really need this for my work :S