• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

oracle 8i jdbc problem

 
xixi tu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the following error message while running my test program to connect to oracle8i with the jdbc thin driver.
Exception in thread "main" java.lang.NoClassDefFoundError: testOracle2
I checked the classpath and path set and I could not find anything wrong. here is the classpath and path: C:\Oracle\Ora81\jdbc\lib\classes12.zip;
import java.io.*;
import java.sql.*;
class testOracle2
{

public testOracle2( )
{

}

public void getquery()
{

String query="";
try{

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc racle:thin@XIXI:1521:XIXI","system","manager");

Statement stmt= con.createStatement();

query="select id from test";
ResultSet results = stmt.executeQuery(query);

while (results.next()){
int id=results.getInt("id");
System.out.println(id);
}

stmt.close();
con.close();

}catch (SQLException e) {
}
catch (java.lang.ClassNotFoundException e){


};

}
public static void main(String s[]) {

testOracle2 test = new testOracle2();

test.getquery();



}


}
Thanks in advance :-)
 
Jack Turtz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should add the directory of your testOracle2.class file to your classpath. Your main method calls a class that you have declared and therefore needs to know where to find the code.
If your testOracle2.java file is located in c:\windows\desktop\java_programs\testOracle2.java, you will want to add c:\windows\desktop\java_programs to your classpath.
Jack
[This message has been edited by Jack Turtz (edited October 17, 2001).]
 
xixi tu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack,
I got it. Thanks a lot.
xixi tu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic