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
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?
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
Re: ClassNotFoundException: org.gjt.mm.mysql.Driver
thans i rezsolved the problem a add the jar filr