Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Same old error java.lang.classnotfoundexception sun.jdbc.odbc.jdbcodbcdriver

 
Vineeth Menon
Ranch Hand
Posts: 79
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I know this error is something which has been discussed in the forum before, but could anyone please help me. The following is my code



At first I thought it was a problem with the datasource and I tried a million times with that, then I turned my attention to the JDK. I was using IBM JDK and since I was getting this problem I uninstalled it and installed Sun JDK which made no difference at all. I did however read about making changes to the class path, I did not quite well understand it, but I do have the bin and lib of both JDK and JRE in the class path....guys please let me know if there is anything else left for me to do...

Thanks in Advance.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You didn't spell the name of the class correctly. Actually the error is in one of the package names, not the class name.
 
Vineeth Menon
Ranch Hand
Posts: 79
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh my God I'm such an idiot, thanks a million bro.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure!
 
Vineeth Menon
Ranch Hand
Posts: 79
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

I've got a quick question, I am using Netbeans, so why did it not show me an error in the first place?

Thanks
Vinnie
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling Class.forName() is generally used to get a class whose name is not known at compile time. For example, you could store the actual name of the JDBC driver class in a property file. Even though you used compile-time constant as a parameter, the Java compiler does not try to evaluate the Class.forName() at compile time, and therefore does not detect the error.

The purpose of the command is to load the class definition; initialization code of that class then registers itself as a JDBC driver. You could replace
with

which would serve the same purpose (it would load the sun.jdbc.odbc.JdbcOdbcDriver class), but you'd get compiler and Netbeans warnings if there were misspellings.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic