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

    NoClassDefFoundError : java/sql/Savepoint

      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[])
                DriverManager.registerDriver(new 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");
           }catch(Exception 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
      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
          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,
          • 2. java.lang.NoClassDefFoundError : Employee

            import java.sql.*;

            class Employee
            public static void main (String args[])
            // try {

            // } 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

                 // 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

                      // Close the connection
                 }catch (SQLException e){
                      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
              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,
              • 4. Re: NoClassDefFoundError : java/sql/Savepoint
                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.