hello everyone..
I am trying to connect a simple application to Oracle XE database. But when I run this program , the else part of program is running. Can Anyone tell whether I hav ewritten the code correct or not.

import java.sql.*;
public class jbc
{
    public static void main(String args[])
    {
        int i=0;
        try
        {
            String str="SELECT * FROM adi";
            Class.forName("sun.jdbc.odbc.JdbcOdbcdriver");
            Connection con = DriverManager.getConnection("jdbc:odbc:bm","SYSTEM","monika");
            System.out.println("Connection open");
            Statement stmt=con.createStatement();
            ResultSet rs= stmt.executeQuery(str);
            System.out.println("first Name");
            while(i<3)
            {
                rs.next();
                String lname=rs.getString("name");
                System.out.println(lname);
                i++;
            }
            con.close();
        }
        catch(Exception ex)
        {
            System.out.println("error occurred");
            System.out.println("Error:" +ex);
        }
    }
}

pls post here any error messages if you got or explain your problem briefly

so that we are here to help you

how could we understand the else part the program is running?

Here is the error i am getting.

java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcdriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at jbc.main(jbc.java:10)
BUILD SUCCESSFUL (total time: 2 seconds)

Please solve my problem.

this problem comes mainly with if the rt.jar file could not be found by the application

please let me know how r u running this application?

(at command prompt or using any IDE like netbeans ,eclipse)

r u running your application windows or in unix or linux? (pls specify this also )

if you are running at Command Prompt (in windows):

please check whether the java sdk instalation path (JAVA_HOME) path has been set properly or not

guidelines :

go to mycomputer (right click on it )
-> then go to properties
-> then select 'Advanced System Settings'
-> select "Advanced" tab
-> then select "environment Variables" button
then check
under system variables go for path variable then check whether there is an entry for **(java_Instalation_path) ** or not

let me know all the above things

This question has already been answered. Start a new discussion instead.