Error while running Java program - TechRepublic
General discussion
September 7, 2004 at 09:23 PM
prasannakumar

Error while running Java program

by prasannakumar . Updated 21 years, 10 months ago

Hi friends
Iam new to Java technology.
When I tried to retrieve records from Oracle database to Java using ODBC, the compilation is successful. But I’m getting an error while running the program.
I’m getting output for this program in other systems in which the system JavaHome variable is set as C:\jdk1.3 whereas in my sytem, the variable is C:\j2sdk1.4.0_01

The error is:
Exception in thread “main” java.lang.NoClassDefFoundError: Ret/Class

My program is:
import java.sql.*;
public class Ret
{
public static void main(String a[]) throws Exception
{
try
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection con = DriverManager.getConnection(“jdbc:odbc:team2″,”scott”,”tiger”);
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(“Select * from emp”);
while (rs.next())
{
String str = rs.getString(“ename”);
String j = rs.getString(“job”);
System.out.println(str+” “+j);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}

This discussion is locked

All Comments