Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JDBC driver - java lang ClassNotFoundException

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am tryin to make a connection to oracle database. when i do

Class.forName(oracle.jdbc.driver.OracleDriver);

I am getting

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

My CLASSPATH variable is set to C:\Program Files\Java\jdk1.5.0_06\jre\lib\classes111.zip and C:\Program Files\Java\jdk1.5.0_06\jre\lib\classes12.zip

I have evn set path for ORACLE_HOME/jdbc/lib/classes111.zip and ORACLE_HOME/jdbc/lib/classes12.zip.

but i am still gettin ClassNotFoundException.Most of the resources i have checked are talkinabout Path and classpath. I have checked them but i am pasting them below.

CLASSPATH =
C:\Program Files\Java\jdk1.5.0_06\jre\lib;C:\ProgramFiles\Java\jdk1.5.0_06\jre;C:\oracle\ora81\jdbc\lib\classes111.zip;C:\oracle\ora81\jdbc\lib\classes12.zip;C
:\Program Files\Java\jdk1.5.0_06\jre\lib\classes111.zip;C:\Program Files\Java\jdk1.5.0_06\jre\lib\classes12.zip;C:\Program Files\Java\jdk1.5.0_06\jre\lib\classe
s12.jar;C:\Program Files\Java\jdk1.5.0_06\jre\lib\classes111.jar;.

PATH =
c:\oracle\ora81\bin;C:\Program Files\Oracle\jre\1.1.7\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\IDM Computer Solutions\UltraEdit-32;C:\Program Files\Java\jdk1.5.0_06\bin;C:\oracle\ora81\bin;C:\oracle\ora81\lib;C:\Program Files\Java\jdk1.5.0_06\jre\lib\classes111.zip;C:\Program Files\Java\jd
k1.5.0_06\jre\lib\classes12.zip;.


Thanks in advance
Avneet
 
Avneet Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and also i am using jdk 1.5.

Looking forward for help.Tried this patch on oracle site which asked for class file to be replaced in classes12.zip when we extract it at location
oracle/jdbc/ttc7 - didnt wotk , same error.

Now i hace switched back to the orignal classes12.zip
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Classpath variables are evil and as you can see have done you no good whatsoever.

The bottom line is that your runtime does not have the oracle libraries in it's classpath. You haven't identified how you are running this code.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




My CLASSPATH variable is set to C:\Program Files\Java\jdk1.5.0_06\jre\lib\classes111.zip and C:\Program Files\Java\jdk1.5.0_06\jre\lib\classes12.zip

I have evn set path for ORACLE_HOME/jdbc/lib/classes111.zip and ORACLE_HOME/jdbc/lib/classes12.zip.



While it has nothing to do with the ClassNotFoundException
1) classes111.zip is the driver for Java 1.1, classes12.zip is the driver for Java 1.2 You need to pick one or the other; having both will cause problems.
2) Generally, putting libraries in the jre\lib directory is wrong; they're part of your application and should be kept with your application code.
 
Sheriff
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by stu derby:
2) Generally, putting libraries in the jre\lib directory is wrong; they're part of your application and should be kept with your application code.

And in six months when you decide to download and start using JDK 1.5.0_08, all of a sudden you will have the same problem all over again.
 
Avneet Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys for all your help, i pasted the class12.zip in the jre/lib/ext folder of jdk and then it worked.

This way it stays common for all my applications rather then keeping it with the code.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!