Results 1 to 4 of 4
  1. #1
    sharck is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default ClassNotFoundException: org.gjt.mm.mysql.Driver

    i have this exception this is my code
    /*test1*/
    String username = "root";
    String password = "1234";
    // The URL that will connect to TECFA’s MySQL server
    // Syntax: jdbc:TYPE:machine:port/DB_NAME
    String url = "jdbc:mysql://localhost:3306/contactbd";
    // A canned query string
    String queryString = "SELECT * FROM partenaire";
    // ---- configure END
    // INSTALL/load the Driver (Vendor specific Code)
    try {
    Class.forName("org.gjt.mm.mysql.Driver");
    } catch (java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    }
    try {
    Connection con;
    Statement stmt;
    // Connection to the database at URL with usename and password
    con = DriverManager.getConnection(url,username,password) ;
    System.out.println ("Ok, connection to the DB worked.");
    System.out.println ("Let’s see can retrieve something with: " +
    queryString);
    // Create a Statement Object
    stmt = con.createStatement();
    // Send the query and bind to the result set
    ResultSet rs = (ResultSet) stmt.executeQuery(queryString);
    while (rs.next()) {
    String s = rs.getString("Nom");
    float n = rs.getFloat("Idpar");
    System.out.println(s + " " + n);
    }
    // Close resources
    stmt.close();
    con.close();
    }
    // print out decent error messages
    catch(SQLException ex) {
    System.err.println("==> SQLException: ");
    while (ex != null) {
    System.out.println("Message: " + ex.getMessage ());
    System.out.println("SQLState: " + ex.getSQLState ());
    System.out.println("ErrorCode: " + ex.getErrorCode ());
    ex = ex.getNextException();
    System.out.println("");
    }

    i am working with netbeans 7.0 i did this Class.forName("com.mysql.jdbc.Driver") but the same happend
    i add the to libmysql-connector-java-5.1.18 to the Librerie of my project but the same help me please

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: ClassNotFoundException: org.gjt.mm.mysql.Driver

    Does that jar file contain the class you are attempting to load?
    Is that jar file on the runtime classpath?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    sharck is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: ClassNotFoundException: org.gjt.mm.mysql.Driver

    i dont have a jar file a have a zip file this mysql-connector-java-5.1.18.zip

  4. #4
    sharck is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: ClassNotFoundException: org.gjt.mm.mysql.Driver

    thans i rezsolved the problem a add the jar filr

Similar Threads

  1. Replies: 10
    Last Post: 03-20-2012, 08:23 AM
  2. Replies: 0
    Last Post: 11-06-2011, 12:18 AM
  3. ClassNotFoundException: com.mysql.jdbc.Driver
    By tBKwtWS in forum New To Java
    Replies: 9
    Last Post: 06-15-2011, 07:01 PM
  4. Replies: 4
    Last Post: 03-31-2010, 12:08 PM
  5. Replies: 0
    Last Post: 03-01-2010, 01:03 PM

Posting Permissions

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