Results 1 to 11 of 11

Thread: db2 and JDBC

  1. #1
    Join Date
    Mar 2011
    Posts
    5

    Unanswered: db2 and JDBC

    i am making an application in Java using db2 as backend. I have db2 installed, and using the db2inst1 user, I am able to connect to the database and access the information, but using an existing user, it gives me the ClassNotFoundException. I am using db2 express C 9.7 on ubuntu 10.10.

    pls help

    thnx...

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    What are you trying to execute when you get the exception? What is the full exception you are getting?

    Andy

  3. #3
    Join Date
    Mar 2011
    Posts
    5
    am getting this error...

    java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
    at java.net.URLClassLoader$1****n(URLClassLoader.java :217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at trials.db2query.main(db2query.java:14)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Your JDBC driver is not in your classpath.

    Andy

  5. #5
    Join Date
    Mar 2011
    Posts
    5
    how to set the classpath in linux?

  6. #6
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5

  7. #7
    Join Date
    Mar 2011
    Posts
    5
    how do i set it for the db2 jdbc driver?

  8. #8
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    It depends on where it is. You should check your classpath for db2inst1 and set the classpath to the same thing for the user.

    Andy

  9. #9
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    This is a pure Java question and not related to DB2 at all.

    Firt: Do not change (or use) the CLASSPATH variable, it is no longer needed.

    When starting your application you need to specify the jar files that your application needs:
    Code:
    java -cp myapp.jar;db2java.jar mypackage.MyMain
    For more details refer to the manual:
    http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html

  10. #10
    Join Date
    Mar 2011
    Posts
    5
    setting the classpath didnt work for (might have done it wrong). though, i managed to get it working by including the driver using netbeans. now i am able to connect to the database

    thnx for the response...

  11. #11
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    As I said: do not use CLASSPATH.

    "Including the driver using netbeans" is essentially providing the necessary information for the -cp parameter.

    Please do read the link I posted. This is absolute basic Java knowledge

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •