This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Getting exception while loading Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Getting exception while loading" Watch "Getting exception while loading" New topic
Author

Getting exception while loading

Venkatesh Ram
Greenhorn

Joined: Mar 08, 2007
Posts: 7
Iam using MySql and while using eclipse and tried to load driver with the statement,

Class.forName("com.mysql.jdbc.Driver").newInstance();
iam getting the exception
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

i transferred my code to Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
but again iam getting exception as
caughtjava.lang.ClassNotFoundException: com.mysql.jdbc.Driver

When i use the second code in notepad it is working.Could anybody help me.

Thanks in advance
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You need to make sure the driver is in your classpath. Where have you put the MySQL driver jar file?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2300
Not able to find the class / jar containing the class in the classpath.Look into the scope of the classloader , which is trying to load the class.If its within a webapplication then put the jar in application/WEB-INF/lib folder.


Rahul Bhattacharjee
LinkedIn - Blog
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Getting exception while loading
 
Similar Threads
Multiple loading of a class thru Class.forName() ??
getting re-read error
Class.forName()
Exception at JNDI
Issues regarding Connectionpooling with MySQL database server and Tomcat 5.5 server