2 Replies Latest reply on Aug 1, 2013 6:54 AM by masijade

    Exception in thread "main" java.lang.NoClassDefFoundError:

    CodingLearner

      got a problem in a code-

       

      import java.sql.*;

       

       

      class MyOracle2

      {

        public static void main (String[]args)

         {

          try{

               Class.forName("oracle.jdbc.OracleDriver");

               System.out.println("Driver loaded");

               Connection conn= DriverManager.getConnection

      ("jdbc:oracle:thin@AS4752:1521:orcl","scott","tiger");

               System.out.println("connected to database");

               Statement st=conn.createStatement();

               ResultSet rs=st.executeQuery("select ename,sal from emp");

               while(rs.next())

               {

                 String str=rs.getString("ename");

                 int amt=rs.getInt("sal");

                 System.out.println(str+"\t"+amt);

                }

              conn.close();

             }

          catch(ClassNotFoundException cnf)

            {

               System.out.println("error"+cnf);

            }

            catch(SQLException sq)

            {

               System.out.println("error in database"+sq.getMessage());

             }

       

      }}

       

       

      OUTPUT IS-

      Exception in thread "main" java.lang.NoClassDefFoundError: MyOracle2

      Caused by: java.lang.ClassNotFoundException: MyOracle2

              at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

              at java.security.AccessController.doPrivileged(Native Method)

              at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

              at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

              at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

      Could not find the main class: MyOracle2.  Program will exit

       

      im using oracle 10.2.0.1

                    jdk 1.6.0_24

                    win 7 (x64)

       

      plz help.........