[COLOR="Red"]import java.sql.*;
public class test {
public static void main(String args[]) {
// Define the url for the sample database
String url = "jdbc:derby://localhost:1527/test";
Connection con;
String createString;
createString = "create table test " +
"(NAME varchar(32), " +
"NUMBER int, " +
"FEEs float " ;
Statement stmt;
try {
// Load database driver. This is old method of loading
// database driver.
Class.forName("org.apache.derby.jdbc.ClientDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
// Create database connection
//con = DriverManager.getConnection(url,"app", "app");
con = DriverManager.getConnection(url, "app", "app");
// Create a statement and execute it
stmt = con.createStatement();
stmt.executeUpdate(createString);
// If there is no exception, the COFFEES table must be successfully created
System.out.println("TEST table is successfully created");
// Close statement and connection
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}[/COLOR]
I take new project in Netbeans. With the above coding, i am getting following error when i m trying to run the file test.java
[COLOR="Red"]Compiling 1 source file to C:\Documents and Settings\Administrator\JavaApplication2\build\classes
compile-single:
run-single:
java.lang.NoClassDefFoundError: javaapplication2/test
Exception in thread "main"
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)[/COLOR]
PLEASE HELP ME TO SOLVE THE ERROR.