• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...I'm trying to connect my web-application to MySql (database), from ECLIPSE I am getting a runtime error stating :java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.

I have added the eternal (JAR file) mysql-connector-java-5.1.22.zip. But still I'm getting the error.

The code:
Connection con = null;
try
{
Class.forName("com.mysql.jdbc.Driver"); // This is where the run-time error occurs (ClassNotFoundException)
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/brb","root","123");
Statement st = con.createStatement();
st.executeUpdate("insert into test values('" + name + "','"+ value +"')");
}catch(Exception e)

Note: This works absolutely fine on NetBeans....
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure, but that sounds like a classpath problem. What is the classpath you are using, and how did you add the .jar to the project in Eclipse?
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have added the eternal (JAR file) mysql-connector-java-5.1.22.zip.


That's a zip file not a jar file. The zip contains the jar file and documentation etc.
You will need to extract the jar file from the zip.
 
Ravi Harishchandra
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks ...got it....it was a problem with tomcat libs.....reinstalling solved it.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic