Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting exception while loading

 
Venkatesh Ram
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to make sure the driver is in your classpath. Where have you put the MySQL driver jar file?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic