5 Replies Latest reply on Sep 20, 2002 7:39 PM by 807593

    JDBC Connection with DB2

    807593
      i have db2 v7.2 installed. on the same machine i dvelop java applications.
      i use jdk1.3.1 and i want to connect to a DB2 database.
      i upgraded the jdbc driver to JDBC 2.0
      now i have the following problem:

      Application
      -------------------
      ...
      Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
      System.out.println("Driver loaded");
      con = DriverManager.getConnection("jdbc:db2:dbName","user","passwd");
      System.out.println(" Connected to DB2 database :-) ");
      ...
      CLASSPATH
      ------------------
      when i type 'echo %CLASSPATH%'
      this returns :
      .;c:\SQLLIB\java\db2java.zip;c:\SQLLIB\lib;c:\SQLLIB\java\runtime.zip;c:\SQLLIB\java\sqlj.zip;

      PROBLEM
      ------------------
      Driver loaded
      java.sql.SQLException: No suitable driver
      java.sql.SQLException: No suitable driver
      at java.sql.DriverManager.getConnection(DriverManager.java:537)
      at java.sql.DriverManager.getConnection(DriverManager.java:177)
      at DBtest.getConnection(DBtest.java:30)
      at DBtest.<init>(DBtest.java:12)
      at DBtest.main(DBtest.java:45)

      Please tell me what could be wrong, I really don't know
      THANK YOU
        • 1. Re: JDBC Connection with DB2
          807593
          Have you run the usejdbc2 script (it's in the java12 directory)

          NB you have to shut DB2 down before running it

          HH
          • 2. Re: JDBC Connection with DB2
            807593
            the server was not running when i executed usejdbc2.bat
            • 3. Re: JDBC Connection with DB2
              807593
              forget the duke-dollers i have the answer

              i entered

              java -Djdbc.drivers=DriverClass ApplikationName

              example: java -Djdbc.drivers=COM.ibm.db2.jdbc.app.DB2Driver DBtest

              and it works

              sorry

              HowyC ;-)
              • 4. Re: JDBC Connection with DB2
                807593
                Git it!

                Your code runs fine under

                D:\DB2TEST>java -version
                java version "1.4.0"
                Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
                Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

                But I get the same error using

                D:\DB2TEST>java -version
                java version "1.3.1"
                Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1)
                Classic VM (build 1.3.1, J2RE 1.3.1 IBM Windows 32 build cn131w-20020403 ORB130
                (JIT enabled: jitc))

                I think I've seen this before, and I'm not sure if there is a work round with out updating your JDK. Could try looking throught the JDBC forum.

                HH
                • 5. Re: JDBC Connection with DB2
                  807593
                  i lost my nerves on that !!!!!!

                  i tried it with JDK1.4.0 before i used JDK1.3.1
                  but hey now it works, that is important

                  hey HumbleHobbit i want to thank you for your replies and i transfer you
                  the 10 dukes ;-)

                  it could be that i will have more questions in future
                  i hope you will reply

                  anyway, thank you and stay cool dude

                  with best wishes HowyC