Re: Problem finding SQLite JDBC driver
Please start a new thread for your problem.
Include the console contents when you post.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Re: Problem finding SQLite JDBC driver
Quote:
Originally Posted by
Norm
Please start a new thread for your problem.
Include the console contents when you post.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Thanks for yr reply
This is the program:
**
* ConnectSQLite.java
*/
//package com.javaworkspace.connectsqlite;
import java.sql.*;
/**
* @author
*
*/
public class ConnectSQLite {
public static void main(String[] args) {
Connection connection = null;
ResultSet resultSet = null;
Statement statement = null;
try {
Class.forName("org.sqlite.JDBC");
connection = DriverManager
.getConnection("jdbc:sqlite:C:\\Program Files\\Java\\jre6\\lib\\EMPLOYEE.db");
statement = connection.createStatement();
resultSet = statement
.executeQuery("SELECT EMPNAME FROM EMPLOYEEDETAILS");
while (resultSet.next()) {
System.out.println("EMPLOYEE NAME:"
+ resultSet.getString("EMPNAME"));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
resultSet.close();
statement.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
The program compiles oK but when running it (on Scite editor) this is the message:
>C:\Archivos de programa\Java\jdk1.6.0_21\bin\javac ConnectSQLite.java
>Exit code: 0
>C:\Archivos de programa\Java\jdk1.6.0_21\bin\java -cp . ConnectSQLite
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.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at ConnectSQLite.main(ConnectSQLite.java:20)
java.lang.NullPointerException
at ConnectSQLite.main(ConnectSQLite.java:34)
>Exit code: 0
This source java program is in directory:
C:\Users\Claudio\Desktop\PROGRAMAR\JAVA\MiProyecto
These are the CURRENT values of my system variables:
CLASSPATH:
.;C:\Program Files\Java\jdk1.6.0_21;C:\Program Files\Java\jre6\lib\sqlitejdbc-v056.jar;.;%DERBY_HOME%\lib\derby.jar;.;C:\Users\C laudio\Desktop\PROGRAMAR\JAVA\MiProyecto\SimpleApp ;.
JAVA_HOME:
C:\Program Files\Java\jre6
PATH:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShel l\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Java\jdk1.6.0_21\bin
Many thanks in advance for your help.
(P.D.: I've never had more problems than when trying to install and use any database system in java.
I have experience in installing and using PostgreSQL but not in Java. I used it with Python.
I've installed SQLite and it works ok on console. The problem is when I try to use it in Java.
Have the same problem when try to use JavaDB).
Re: Problem finding SQLite JDBC driver
Quote:
java.lang.ClassNotFoundException: org.sqlite.JDBC
The java program can not find the class listed in the error message. You need to put the jar file containing that class's class file on the classpath.
java -cp <JARFILE>.jar;. <CLASSNAME>
Re: Problem finding SQLite JDBC driver
To add to Norms post, do not rely on CLASSPATH.
You should always define your classpath at execution, using the -cp switch.
One reason is that CLASSPATH is the last place Java goes to find out what classpath it should use. -cp takes precedence, and the manifest in an executable jar takes precedence over that.
Another reason is that if you have mutliple projects on one box not all of them will want to use the same versions of jar files.
Re: Problem finding SQLite JDBC driver
Also, next time you have a question start your own thread -- they're free. This one's tow years old.
I'm splitting the current discussion to a new thread.
db
Re: Problems with CLASSPATH