Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    1

    Unanswered: MySQL JDBC driver class not found

    Hi,
    I'm having problem trying to connect to mysql using java application, it gives a classnot found exception, the classpath that I've specified is given below
    .;c:\mysql\mysql-connector-java-3.0.9-stable-bin.zip;c:\oracle\ora92\jdbc\lib\classes12.zip;c:\ oracle\ora92\jdbc\lib\nls_charset12.zip;c:\oracle\ ora92\sqlj\lib\translator.zip;c:\oracle\ora92\sqlj \lib\runtime.zip;

    I did not have any problem connecting to oracle using classes12.zip jdbc drivers, the pertinent java codes are given below
    import sql.*;
    import io.*;
    import java.net.*;

    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    hostString="jdbc:mysql://"+server+":"+port+"/"+dbase;
    myConnection=DriverManager.getConnection (hostString, username,password);

    The problem is that it gives the following exception
    java.lang.ClassNotFoundException:com.mysql.jdbc.Dr iver
    same is the case if I use org.gjt.mm.mysql.Driver
    I tried expanding the zip file and giving the path in classpath, but it does not work. Any help is highly appreciated
    Thank you very much

  2. #2
    Join Date
    Dec 2003
    Posts
    2
    The only suggestions I have are these. I haven't seen using the newInstance() method called when loading the driver - simply use Class.forName("com.mysql.jdbc.Driver"); to load the driver.

    If it still doesn't work, then your code should be throwing an exception. Catch the exception and use the getMessage method to see if you can see anything odd about the error.

  3. #3
    Join Date
    Jan 2004
    Posts
    2
    What's inside your"\mysql-connector-java-3.0.9-stable-bin.zip", actually, your must add only "mysql-connector-java-2.0.14-bin.jar" in your CLASSPATH. Basically, this file is packed inside zip file that you got from mysql site. Try to unzip it and find jar file and put it in your classpath
    cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •