jeepzy3
02-03-2003, 08:30 PM
I have this really easy piece of code which I can't seem to run. This code was cut n pasted.
The compile was fine, but when I run I get:
Exception in thread "main" java.lang.NoClassDefFoundError: DBTest
//code begin
import java.sql.*;
import java.io.*;
public class DBTest {
/**************************************
* You MUST change the url user and password
* to reflect your configuration
*/
String url = "jdbc:oracle:thin:@xxxxxxxx:1521:xxxxxxx";
String user = "xxxx";
String password = "xxxxxxxx";
public DBTest() {
}
public void getVersion () {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection (url,user, password);
DatabaseMetaData meta = con.getMetaData();
System.out.println("Database Product Name:" +
meta.getDatabaseProductName());
System.out.println("Database Product Version:" +
meta.getDatabaseProductVersion());
System.out.println("JDBC Driver Name:" +
meta.getDriverName());
System.out.println("JDBC Driver Version:" +
meta.getDriverVersion());
System.out.println("JDBC Driver Major Version:" +
meta.getDriverMajorVersion());
System.out.println("JDBC Driver Minor Version:" +
meta.getDriverMinorVersion());
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
DBTest app = new DBTest();
app.getVersion();
}
}
//code end
When I am running the command to run, I am in the same directory as where DBTest.class is located.
If I specify the full path to the DBTest.class, I get the same error.
The compile was fine, but when I run I get:
Exception in thread "main" java.lang.NoClassDefFoundError: DBTest
//code begin
import java.sql.*;
import java.io.*;
public class DBTest {
/**************************************
* You MUST change the url user and password
* to reflect your configuration
*/
String url = "jdbc:oracle:thin:@xxxxxxxx:1521:xxxxxxx";
String user = "xxxx";
String password = "xxxxxxxx";
public DBTest() {
}
public void getVersion () {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection (url,user, password);
DatabaseMetaData meta = con.getMetaData();
System.out.println("Database Product Name:" +
meta.getDatabaseProductName());
System.out.println("Database Product Version:" +
meta.getDatabaseProductVersion());
System.out.println("JDBC Driver Name:" +
meta.getDriverName());
System.out.println("JDBC Driver Version:" +
meta.getDriverVersion());
System.out.println("JDBC Driver Major Version:" +
meta.getDriverMajorVersion());
System.out.println("JDBC Driver Minor Version:" +
meta.getDriverMinorVersion());
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
DBTest app = new DBTest();
app.getVersion();
}
}
//code end
When I am running the command to run, I am in the same directory as where DBTest.class is located.
If I specify the full path to the DBTest.class, I get the same error.