Subject: error:exception in thread main java.lang.noclassde
Posted By: sara.j Post Date: 12/12/2006 11:35:16 PM
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").newinstance();
     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.


Go to topic 53553

Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89
Return to index page 88
Return to index page 87
Return to index page 86