Skip to Main Content

Java Development Tools

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Connecting Sqlite with JDeveloper

ezez85Sep 22 2009 — edited Sep 23 2009
Hi guy,

I am new to Jdeveloper and i am trying to connect the application i create to the SQLite. I setup the SQLite through the connection Create Database Wizard. However, when i run,
error occur.
java.lang.ClassNotFoundException: org.sqlite.JDBC

I tried to search but there are little about using oracle and sqlite. Is there any step i miss when i create the connection. Thank a lot!!!

this is my sample code:

import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.ResultSetMetaData;
import java.sql.DatabaseMetaData;

public class HelloDatabase
{
public static void main (String[] args)
{
// register the driver
String sDriverName = "org.sqlite.JDBC";
try
{
Class.forName(sDriverName);
}
catch(Exception e)
{
System.err.println(e);
}

// now we set up a set of fairly basic string variables to use in the body of the code proper
String sTempDb = "sample.db";
String sJdbc = "jdbc:sqlite"; String sDbUrl = sJdbc + ":" + sTempDb;
// which will produce a legitimate Url for SqlLite JDBC :
// jdbc:sqlite:hello.db
int iTimeout = 30;
String sMakeTable = "CREATE TABLE dummy (id numeric, response text)";
String sMakeInsert = "INSERT INTO dummy VALUES(1,'Hello from the database')";
String sMakeSelect = "SELECT response from dummy";
try
{ // create a database connection
Connection conn = DriverManager.getConnection(sDbUrl);
Statement stmt = conn.createStatement();
stmt.setQueryTimeout(iTimeout);
stmt.executeUpdate( sMakeTable );
stmt.executeUpdate( sMakeInsert ); ResultSet rs = stmt.executeQuery(sMakeSelect);
while(rs.next())
{
String sResult = rs.getString("response");
System.out.println(sResult);
}
}
catch(SQLException e)
{
// connection failed.
System.err.println(e);
}
}

}
This post has been answered by Shay Shmeltzer-Oracle on Sep 22 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 21 2009
Added on Sep 22 2009
2 comments
1,904 views