csvjdbc class loading problem

M

MyClue

Hey everyone. I'm trying to use csvjdbc.jar, a driver for reading
comma-separated flat-files as a database (search on sourceforge for
csvjdbc). In the example code that I have, it says to include the
following line:

Class.forName("org.relique.jdbc.csv.CsvDriver");

However when I run the app, it throws this error:

ClassNotFoundException: org.relique.jdbc.scv.CsvDriver

I'm sure my classpath is set correctly. Anybody else run into this
problem? Any help would be appreciated. Thanks
 
J

jagonzal

MyClue said:
Hey everyone. I'm trying to use csvjdbc.jar, a driver for reading
comma-separated flat-files as a database (search on sourceforge for
csvjdbc). In the example code that I have, it says to include the
following line:

Class.forName("org.relique.jdbc.csv.CsvDriver");

However when I run the app, it throws this error:

ClassNotFoundException: org.relique.jdbc.scv.CsvDriver

I'm sure my classpath is set correctly. Anybody else run into this
problem? Any help would be appreciated. Thanks

ClassNotFoundException would indicate that either there's a typo in the
class name supplied, or your classpath isn't correctly set.
 
J

jagonzal

MyClue said:
Hey everyone. I'm trying to use csvjdbc.jar, a driver for reading
comma-separated flat-files as a database (search on sourceforge for
csvjdbc). In the example code that I have, it says to include the
following line:

Class.forName("org.relique.jdbc.csv.CsvDriver");

However when I run the app, it throws this error:

ClassNotFoundException: org.relique.jdbc.scv.CsvDriver

I'm sure my classpath is set correctly. Anybody else run into this
problem? Any help would be appreciated. Thanks

Is that Exception copy-pasted from your console? Because it looks like
you have a typo in the class name (it reads "scv" where it should be
"csv")
 
M

MyClue

aah no not copy pasted so that typo was when i made this message.
here's the copy-paste text

java.lang.ClassNotFoundException: org.relique.jdbc.csv.CsvDriver
 
J

jagonzal

MyClue said:
aah no not copy pasted so that typo was when i made this message.
here's the copy-paste text

java.lang.ClassNotFoundException: org.relique.jdbc.csv.CsvDriver

How are you defining your classpath? ClassNotFoundException should not
be thrown if the csvjdbc jar was in the classpath.
 
M

MyClue

i've tried moving the .jar from the set classpath to the same dir as
the .class (and running java -cp . blabla

neither seems to work. i tried the same thing with another driver,
xmljdbc and that one doesn't work either.
 
J

jagonzal

MyClue said:
i've tried moving the .jar from the set classpath to the same dir as
the .class (and running java -cp . blabla

neither seems to work. i tried the same thing with another driver,
xmljdbc and that one doesn't work either.

At the risk of pointing out the blatantly obvious, it is not enough to
point to the directory - you must explicitly name the jar in the
classpath:

Test.java:
public class Test {
public static void main(String args[]) throws Exception{
Class.forName("org.relique.jdbc.csv.CsvDriver");
System.out.println("I'm ok!");
}
}

jgonzalez@jambi ~/downloads/csvjdbc-r0-10 $ java Test
Exception in thread "main" java.lang.ClassNotFoundException:
org.relique.jdbc.csv.CsvDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at Test.main(Test.java:3)

jgonzalez@jambi ~/downloads/csvjdbc-r0-10 $ java -classpath
..:csvjdbc.jar Test
I'm ok!

Note that the "classpath" isn't just "." - it explicitly names
csvjdbc.jar as a separate classpath element from "."
 
M

MyClue

aah, thanks a bunch.
<-- beginner ;)

MyClue said:
i've tried moving the .jar from the set classpath to the same dir as
the .class (and running java -cp . blabla

neither seems to work. i tried the same thing with another driver,
xmljdbc and that one doesn't work either.

At the risk of pointing out the blatantly obvious, it is not enough to
point to the directory - you must explicitly name the jar in the
classpath:

Test.java:
public class Test {
public static void main(String args[]) throws Exception{
Class.forName("org.relique.jdbc.csv.CsvDriver");
System.out.println("I'm ok!");
}
}

jgonzalez@jambi ~/downloads/csvjdbc-r0-10 $ java Test
Exception in thread "main" java.lang.ClassNotFoundException:
org.relique.jdbc.csv.CsvDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at Test.main(Test.java:3)

jgonzalez@jambi ~/downloads/csvjdbc-r0-10 $ java -classpath
.:csvjdbc.jar Test
I'm ok!

Note that the "classpath" isn't just "." - it explicitly names
csvjdbc.jar as a separate classpath element from "."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top