3 Replies Latest reply: Jul 29, 2013 2:30 PM by jschellSomeoneStoleMyAlias RSS

    java.lang.ClassNotFoundException : oracle.jdbc.OracleDriver

    CodingLearner

      hello i have problem with my code, the code is:

       

      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- error java.lang.ClassNotFoundException : oracle.jdbc.OracleDriver

       

      i am using jdk 1.6.0_24

      and Oracle Database 10g Enterprise Edition Release 10.2.0.1.0

      Windows 7 (x64)

      i tried 2 classpath

      classpath=C:\oracle\product\10.2.0\db_1\jdbc\lib\classes12.jar:%classpath%;

      classpath=C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar:%classpath%;

       

      same problem arises in both cases.

       

      pls help