classnotfound exception in jdbc
Hey guys.i am new to jdbc.i've used mysql.i installed my mysql connector/j in jdk1.6_0_11/jre/lib/ext path.I use netbeans to write my code;
Here is my code
Code:
package jdbctrial;
import java.sql.*;
/**
*
* @author Tariq Ibrahim
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args)throws Exception {
// TODO code application logic here
try {
Statement stmt;
Class.forName("com.mysql.jdbc.Driver");
String url =
"jdbc:mysql://localhost:3306/mysql";
Connection con =
DriverManager.getConnection(
url,"root", "");
System.out.println("URL: " + url);
System.out.println("Connection: " + con);
stmt = con.createStatement();
stmt.executeUpdate(
"CREATE DATABASE JunkDB");
stmt.executeUpdate(
"GRANT SELECT,INSERT,UPDATE,DELETE," +
"CREATE,DROP " +
"ON JunkDB.* TO 'auser'@'localhost' " +
"IDENTIFIED BY 'drowssap';");
con.close();
}catch( Exception e ) {
e.printStackTrace();
}//end catch
}//end main
}//end class Jdbc11
i get this exception when running
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at jdbctrial.Main.main(Main.java:24)