4 Replies Latest reply on Mar 4, 2005 6:43 PM by 112030

    NoClassDefFoundError : java/sql/Savepoint

    437265
      I am using j2sdk1.4.2_06 and ojdbc14.jar.
      The problem is I am unable to make a connection to oracle from a simple java code.

      This is the code:

      import java.sql.*;


      class DmTest
      {
           public static void main(String st[])
           {
                try{
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                //Class.forName("oracle.jdbc.driver.OracleDriver");
                Connection con=DriverManager.getConnection("jdbc:oracle:thin:@myhost:1521:PAYLINK","scott","tiger");
                
                /*Statement stmt=con.createStatement();
                ResultSet rs=stmt.executeQuery("select * from emp");
                
                if(rs.next())
                {
                     System.out.println(rs.getString(1));
                }*/
           }catch(Exception e)
           {
                System.out.println(e);
           }
           }
      }


      This is the exception:

      Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Savepoint
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.access$100(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClassInternal(Unknown Source)
      at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
      va:547)
      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:347)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at DmTest.main(DmTest.java:11)

      What could be the problem?
      Thanx in advance
        • 1. Re: NoClassDefFoundError : java/sql/Savepoint
          Avi Abrami
          434262,
          Your query is not supported by the JDBC driver you are using. You can find more details in the Oracle "JDBC Developer's Guide and Reference". Look for the section entitled "Result Set Limitations". Try replacing the "*" in your query with an explicit list of columns.

          Good Luck,
          Avi.
          • 2. java.lang.NoClassDefFoundError : Employee
            437809




            import java.sql.*;

            class Employee
            {
            public static void main (String args[])
            {
            // try {
                 //Class.forName("oracle.jdbc.driver.OracleDriver");

            // } catch (ClassNotFoundException x){  System.out.println("error "+x);     }

            try {
                      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

                      System.out.println ("hello");
                 Connection conn =
                 DriverManager.getConnection("jdbc:oracle:thin:@host:1521:database","scott", "tiger");

                 //port: default is 1521
            //DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","dchinh05");


                 // Create a Statement
                 Statement stmt = conn.createStatement ();

                 // Select the ENAME column from the EMP table
                 ResultSet rset = stmt.executeQuery ("select studentID,fName from students");

                 // Iterate through the result and print the employee names
                 while (rset.next ())
                 {
                 System.out.println ("hello");
                      System.out.println (rset.getString (1)+" "+rset.getString (2));
                      }
                 // Close the statement
                      stmt.close();

                      // Close the connection
                      conn.close();
                 }catch (SQLException e){
                      System.out.println("error");
                      e.printStackTrace();     }

            }
            }

            I got message : java.lang.NoClassDefFoundError
            I already set classpath = c:\....\..\ojdbc.jar

            any one help ?
            • 3. Re: java.lang.NoClassDefFoundError : Employee
              Avi Abrami
              Anh,
              Please provide the entire error message and stack trace you are getting, as well as the command you use to run your "Employee" class.

              The JDBC driver file is "ojdbc14.jar" -- not "ojdbc.jar" (as you have posted).

              Good Luck,
              Avi.
              • 4. Re: NoClassDefFoundError : java/sql/Savepoint
                112030
                The java.sql.Savepoint class might indicate that you are not using a 1.4 jdk. This is part of the JDBC 3.0 api included in the 1.4 jdk. You may be able to roll back to an earlier Oracle jdbc driver that will not require a 1.4 jdk or ensure that you are referencing a 1.4 jdk.