error:exception in thread main java.lang.noclassde
i have entered the following code in notepad for creating table
import java.sql.*;
Public class CreateTable {
public static void main(string args[]){
connection con=null;
try{
class.forname("org.gjt.mm.mysql.driver").newinstan ce();
SYSTEM.OUT.PRintln("JDBC Driver loaded");
con=drivermanager.getconnection(
"jdbc:mysql://localhost/wrox?user=root&password=q1w2e3");
SYSTEM.OUT.Println("Database connection established");
statement stmt=con.createstatement();
string upd="Create table author(
Author_id Integer NOT NULL PRIMARY KEY,
Author_name char(50));";
stmt.executeupdate(upd);
System.out.println("Table-Author created");
}
Catch (ClassNotFoundException cnfe){
system.out.println("ClassNotFoundException:could not locate Driver");
}catch(SQLException cnfe){
system.out.println("SQLException:+Cnfe);
}Catch(Exception e){
system.out.println("AN unknown error occured while connecting TO THE Database");
}finally {
try {
if(con!=null)
con.close();
}catch(SQLException sqle){
SYStem.out.println("unable to close database connection.");
}
}
}
}
when i try to run >java CreateTable i am getting the following error:exception in thread main java.lang.noclassdef found:CreateTable.
pls help.
|