3 Replies Latest reply on Dec 30, 2011 6:29 AM by 907307

    JDBC class not found

    881147

      hi guys ,

      i try to connect to DB with this code with using eclipse but it give me the msg i write in catch statement(unable).But when i try to connect to same DB with ij tool i could establish the connection and write sql statements(update etc).i could not figure out what the problem is .any idea?

      try { String className = "org.apache.derby.jdbc.EmbeddedDriver";  // path of driver class Class.forName (className);                                  String dbUrl = "jdbc:derby:firstdb"; Connection conn = DriverManager.getConnection(dbUrl); conn.close ( ); } //end try catch(ClassNotFoundException e) { System.out.println ("Unable"); }
        • 1. Re: JDBC class not found
          gimbal2
          The Apache derby driver jar is not going to be on the project classpath automatically, you will need to add it.

          If you don't know any of what I just said, I seriously suggest you study what the Java classpath is before you ask any more questions. Also learn how the classpath is managed in an Eclipse project.
          • 2. Re: JDBC class not found
            EJP
            i try to connect to DB with this code with using eclipse but it give me the msg i write in catch statement(unable).
            Whatever 'unable' is supposed to mean to anybody ...
                      catch(ClassNotFoundException e) {
                           System.out.println ("Unable");
                           }
            When you get an exception, always print out or log the original exception. Never just substitute your own message. Otherwise you are throwing away potentially useful debugging information.
            • 3. Re: JDBC class not found
              907307
              hey Garibanus,
              qimbal2 is correct in eclipse you need to add jar files externally



              for this you can follow these easy steps.........

              1> right click on java project
              2> click on properties tab
              3> click the third link on left hand side "add external jars"
              4> then add the derby driver to project.......


              may this will help you.............