7 Replies Latest reply: May 3, 2012 12:40 AM by 901163 RSS

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


      Hello all!
      I'm trying to connect to a 10g Oracle DB ( from Java code using jdbc. however i get the error below when i try to run the following code in Eclipse. could you please help me out here. Thnx so much in advance.

      import java.sql.*;

      public class CreateCoffees {

      public static void main(String args[]) {
      String host="Francis-PC";
      int port=1521;
      String sid="orcl";
      String url = "jdbc:oracle:thin:@" host":"+port+":"+sid;
      Connection con;
      String createString;
      createString = "create table COFFEES " +
      "(COF_NAME VARCHAR2(32), " +
      "SUP_ID NUMBER, " +
      "PRICE NUMBER(4,2), " +
      "SALES NUMBER, " +
      "TOTAL NUMBER)";

      Statement stmt;
      try {

      catch(java.lang.ClassNotFoundException e) {
      System.err.print("ClassNotFoundException: ");
      try {
      con = DriverManager.getConnection(url,"abiri", "abel");
      stmt = con.createStatement();
      catch(SQLException ex) {
      System.err.println("SQLException: " + ex.getMessage());

      Exception in thread "main" java.lang.NoClassDefFoundError: oracle/dms/instrument/ExecutionContextForJDBC
      at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:341)
      at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
      at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:816)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at CreateCoffees.main(CreateCoffees.java:30)
      Caused by: java.lang.ClassNotFoundException: oracle.dms.instrument.ExecutionContextForJDBC
      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)
      ... 7 more