Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trying to get JAVA to work with SQLite

843859Mar 20 2008 — edited Mar 21 2008
Hello,
I am trying to get java to work with SQlite using the following code:

import java.sql.*;

public class Main {

public static void main(String[] args) throws Exception {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT Question, Answer, Type FROM Questions");
while (rs.next()) {
System.out.println(rs.getString("1"));
System.out.println(rs.getString("2"));
System.out.println(rs.getString("3"));
}
rs.close();
conn.close();
}
}

But when I try to compile I keep getting the exception:

Exception in thread "main" java.lang.ClassNotFoundException: org.sqlite.JDBC

I have looked around other forums and I think I have downloaded the correct drivers for the SQLiteJDBC:
sqlitejdbc-v043-native.jar and sqlitejdbc.dll from http://www.zentus.com/sqlitejdbc/.

I have read that these files need to be put on the classpath and the java library paths respectively however I am unsure how to do this. Also if I do manage to get these files onto their paths would the same have to be done on every computer that I want to run this program on?

Many thanks

Mark
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 18 2008
Added on Mar 20 2008
10 comments
3,947 views