• 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

JDBC and MySQL Problem

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,

Hope someone can help me because I'm getting awfully frustrated.

I am getting the following error upon trying to connect my servlet to a MySQL database:

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

I have downloaded the MySQL/J Connector. I have updated my CLASSPATH so that it points to:

C:\Program Files\Java\jdk1.5.0_05\jre\lib\ext\mysql-connector-java-3.1.12\mysql-connector-java-3.1.12-bin.jar

My connection string looks like this:

Class.forName("com.mysql.jdbc.Driver");

Any ideas?

Thanks in advance
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i run into a similar problem: i unziped the driver jar and added the 'com.etc.' package to classpath, but i guess this is a brute force way
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure why it isn't found, are you running a web application (eg Tomcat)?

One way which may fix it is to move the JAR up one directory to C:\Program Files\Java\jdk1.5.0_05\jre\lib\ext rather than in the mysql-connector-java-3.1.12 directory.

This will add the classes as an extension to the JRE and it is an incredibly brute force way to go about things. It's about as public as you can possibly make a library, which isn't necessarily a good thing. (Oh, you can also remove it from you class path since the classes will be discovered and made available in the same way that the Core Java rt.jar classes are discovered.)

But at this stage lets just aim to get it working.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry to interrup the main thread, but just to say in my case is a stand alone java app
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


are you running a web application (eg Tomcat)?



Or an IDE, such as NetBeans or Eclipse? Projects in those have a different way of setting classpath.
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Hoffman:
[QB]Hi Folks,
I have downloaded the MySQL/J Connector. I have updated my CLASSPATH so that it points to:



Incorrect. Configuring a classpath environment variable will have no effect on your servlet engine.

Consult the docs for your servlet engine to find out how to use additional jars to it's classpath.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic