I recently started working with Java (after years of .Net) and one of the first things I need to do is connect to a database (in this case, Oracle).
Looking around online, it looks like the standard approach is to use JDBC and grab an Oracle JDBC driver - which I promptly did. Specifically, I pulled down ojdbc6.jar (since I'm running jdk6), and tried one of the simpler examples I saw online.
It didn't work.
I went back and read online docs, tutorials, and even posts from here - they were all informative, but didn't say anything about the actual installation process (or made it sound like I have to actually install Oracle itself on this workstation in order to access a remote Oracle db). Feeling like a neanderthal, I decided I should just give up and ask.
The key issue I'm having is that "oracle.jdbc.driver.OracleDriver" is not recognized. Specifically:
returns a NoClassDefFoundError exception.
I tried other .jar files (and learned what a .jar was in the process), toyed with my classpath for a couple of grueling hours, and cursed technology in between sobs.
My classpath, as it is now, reads as follows:
".; c:\java; c:\java\ojdbc6.jar"
The specific error reads as follows:
> java oracle.jdbc.OracleDriver
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at java.net.TooDumbToMakeItWork(Unknown Source)
Could not find the main class: oracle.jdbc.driver.OracleDriver. Program will exit.
I've also tried variations of that class path, reordering them and leaving parts out, mostly because I have no idea what else to do.
The installation process was mostly to download that .jar file and drop it into the directory I was working from (and setting classpath to point to it). I also tried other .jar files, though I have no idea if it's seeing them at all.
However, if I do this:
> java -jar ojdbc6.jar
It responds with this:
Oracle 184.108.40.206.0-Production JDBC 4.0 compiled with JDK6
So... any suggestions? Is this just a matter of me blatantly misunderstanding the basic mechanics of Java? Is there a critical step in the installation that I've left out?
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver
For me showing this error when connected with my application - "java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver".
Opened the Project properties page - Select the libraries column and Add JAR/Folder button to add the files from the "reference/jdbc Driver/oracle and the ...jar files" . now run the application and working correctly.
So give the reference file path correctly.