Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem on JDBC, classpath and Oracle dirver

Status
Not open for further replies.

volcano

Programmer
Aug 29, 2000
136
HK
Hello, I have a simple java application that will retrieve data from a Oracle table via JDBC. The code is shown below. The program can be compiled successfully. But when running it (java TEST), it throws ClassNotFoundException error. If I run with classpath supplied (java -classpath /u01/xxx/xxx/classes12.jar TEST), it has NoClassDefFoundError error. Do you think what's wrong with what I did? I use jdk 1.2.2 to compile. Thanks for your advice!

---------------------------
import java.io.*;
import java.net.URL;
import java.sql.*;

public class TEST {

public static void main (String[] args) throws Exception {

// ********** insert data to database (start) **************
System.out.println("Start connecting...");

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:eek:racle:thin:mad:HOST:DB", "XXXX", "YYYY");

Statement sql = conn.createStatement();
ResultSet result = sql.executeQuery("select * from TABLE");

String abc = null;
abc = result.getString("abc");

// ********** insert data to database (end) **************

System.out.println("abc = " + abc);
conn.close();
}
}
 
Stick classes12.zip in %JAVA_HOME%\jre\lib\ext and youshould be OK.
 
Hi sedj, it's u again. Thanks for your help! I found I can run the program by the following command:
java :/u01/xxx/xxx/classes12.jar TEST

the difference is the addition of ":"....

btw, I encounter another problem here. I run the program using sdk 1.4.1. But my production server is using jdk 1.2.2. I search for java.sun.com that jdk1.2.2 seems to not support XML(?). I am not sure of it. Do u have any idea?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top