help! : java.lang.ClassNotFoundException
Posted by: M K
Date: May 07, 2005 02:53AM

i'm a newbie to jdbc and was trying out a basic program to connect to the database. i'm gettin the same
error msg as a few others were but still cant figure out whats wrong. my output to the program pasted below was:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at Jdbc11.main(Jdbc11.java:12)

The program code i used was:

import java.sql.*;
import java.sql.DriverManager;


public class Jdbc11 {
public static void main(String args[]){
System.out.println(
"Copyright 2005, MK");
try {
Statement stmt;

Class.forName("com.mysql.jdbc.Driver"); //registering jdbc driver

//classes

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();
} //end try
catch( Exception e ) {
e.printStackTrace();
}//end catch

}//end main
}//end class Jdbc11

i've included the sqldriver jar file in C:\j2sdk1.4.2_08\jre\ext . isn't that sufficient? is there a difference in the commands to run this program or?
please help! :/

Options: ReplyQuote


Subject
Written By
Posted
help! : java.lang.ClassNotFoundException
M K
May 07, 2005 02:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.