0

I'm trying to set up a simple database for an Android app using sqlite but got the following error:

java.lang.ClassNotFoundException: org.sqlite.JDBC
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:171)
    at testDB.main(testDB.java:16)

Here is my code:

public class testDB {
    public static void main(String args[]) {
        Connection c = null;
        try {
            Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:/Users/Dropbox/csProject/test.db", "", "");
        } 
    }

I have added sqlite-jdbc4-3.8.2-SNAPSHOT.jar in the library and I also tried to create a path in my home directory but am still getting the same error..

user3286170
  • 1
  • 1
  • 1
  • 1

2 Answers2

1

You have to add the .jar to your project. You can simply do that by opening Eclipse, right click the .jar files, then add to project.

Erik Ghonyan
  • 428
  • 4
  • 12
safaiyeh
  • 1,575
  • 3
  • 15
  • 34
0

You can directly add sqlite-jdbcXXX.jar to your tomcat/lib.