Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

mysql connector/j

807599Mar 6 2007 — edited Mar 6 2007
package mysqlTest;

import java.sql.*;

public class NewClass{
  public static void main(String[] args){
    try{
        
      Class.forName("com.mysql.jdbc.Driver").newInstance(  );
      Connection conn = DriverManager.getConnection(
              "jdbc:mysql://localhost:3306/test",
              "root","****");
      ResultSet cursor = conn.createStatement(  ).executeQuery(
         "INSERT into javatest VALUES('Steve', 'Granet')");
      conn.close(  );
    }
    catch (Exception e){
      System.err.println(e);
    }
  }
}
okay im using netbeans, the newest versions of mysql, connector/j, jdk, everything right. and this file compiles fine, but when i run it i get an error...

init:
deps-module-jar:
deps-ear-jar:
deps-jar:
compile-single:
run-main:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
BUILD SUCCESSFUL (total time: 1 second)


now i added the connection to netbeans, all worked fine right, i can connect to my database, but when i do it through my own code it doesnt work.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 3 2007
Added on Mar 6 2007
13 comments
332 views