rookie1010
Senior member
hey i tried to run this java code after compiling it
&
and when i tried to rn the code i get the following errors
E:\Work\programming\java\JavaPrograms>java rundb
Exception in thread "main" java.lang.NoClassDefFoundError: rundb (wrong name: Ru
nDB)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)
E:\Work\programming\java\JavaPrograms>
what have i done wrong
(i got the code of the following site
http://www.developer.com/design/art...10925_3571661_3
i have got the code in this folder
E:\Work\programming\java\JavaPrograms
and the database in this folder
E:\Work\programming\java\database
// JDBC|Test ? complete code
public class JDBCTest {
public static void main(String args[]){
RunDB runDB = new RunDB();
try{
runDB.loadDriver();
runDB.makeConnection();
runDB.buildStatement();
runDB.executeQuery();
}catch(Exception e){
e.printStackTrace();
}
}
}
&
//RunDB
import java.sql.*;
public class RunDB {
Connection connection;
Statement statement;
public void loadDriver() throws ClassNotFoundException{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
public void makeConnection() throws SQLException {
connection=
DriverManager.getConnection("jdbc: odbc: PurchaseOrder");
}
public void buildStatement() throws SQLException {
statement = connection.createStatement();
}
public void executeQuery() throws SQLException {
boolean foundResults =
statement.execute("SELECT * FROM Transaction");
if(foundResults){
ResultSet set = statement.getResultSet();
if(set!=null) displayResults(set);
}else {
connection.close();
}
}
void displayResults(ResultSet rs) throws SQLException {
ResultSetMetaData metaData = rs.getMetaData();
int columns=metaData.getColumnCount();
String text="";
while(rs.next()){
for(int i=1;i<=columns;++i) {
text+="<"+metaData.getColumnName(i)+">";
text+=rs.getString(i);
text+="</"+metaData.getColumnName(i)+">";
text+="n";
}
text+="n";
}
System.out.println(text);
}
}
and when i tried to rn the code i get the following errors
E:\Work\programming\java\JavaPrograms>java rundb
Exception in thread "main" java.lang.NoClassDefFoundError: rundb (wrong name: Ru
nDB)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)
E:\Work\programming\java\JavaPrograms>
what have i done wrong
(i got the code of the following site
http://www.developer.com/design/art...10925_3571661_3
i have got the code in this folder
E:\Work\programming\java\JavaPrograms
and the database in this folder
E:\Work\programming\java\database