Results 1 to 5 of 5

Thread: JDBC drivers

  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Question Unanswered: JDBC drivers

    Hi
    I just installed DB2 Personal Edition V8 on a WinXP system

    Where do I get and how do I install the JDBC driver for DB2
    i read somewhere (but forgot the page) that DB2 comes with JDBC drivers. Just dont know how to install it and use it.

    Also can someone tell me how to make a connection?

    i found this on the java.sun.com website

    Connection con = DriverManager.getConnection(url,
    "myLogin", "myPassword");

    String url = "jdbcdbc:Fred";

    I get what the myLogin and myPasswords
    but whats in the URL?

    My database is a local install
    The name of the instance the setup program made is "DB2"
    the database in there i want to connect to is called "mytest"

    Any help would be great

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: JDBC drivers

    You are right ... DB2 comes with JDBC Drivers ... DB2 Supports Type1,2, 3 and 4 drivers ... Type 3 will be depracated soon ... Hence do not use type 3 ...

    C:\Program Files\IBM\SQLLIB\java\sqljava.zip has the drivers

    and
    C:\Program Files\IBM\SQLLIB\samples\java
    has examples

    HTH

    Sathyaram



    Originally posted by cstrife
    Hi
    I just installed DB2 Personal Edition V8 on a WinXP system

    Where do I get and how do I install the JDBC driver for DB2
    i read somewhere (but forgot the page) that DB2 comes with JDBC drivers. Just dont know how to install it and use it.

    Also can someone tell me how to make a connection?

    i found this on the java.sun.com website

    Connection con = DriverManager.getConnection(url,
    "myLogin", "myPassword");

    String url = "jdbcdbc:Fred";

    I get what the myLogin and myPasswords
    but whats in the URL?

    My database is a local install
    The name of the instance the setup program made is "DB2"
    the database in there i want to connect to is called "mytest"

    Any help would be great
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Mar 2004
    Posts
    5
    thanks for the reply
    but got 2 issues

    1) how do i "install" the jdbc drivers or have it used when i type "javac testdb.java"

    2) the samples in the directory you pointed me to all use a Class called Db but i cant see that class anywhere or how to tell the program which Database to connect to because they're all connecting to the sample database


    Thanks

  4. #4
    Join Date
    Nov 2003
    Location
    India
    Posts
    6
    Set your classpath to "D:\Program Files\IBM\SQLLIB\java\db2jcc.jar;"
    Try this. This should work fine!
    ------------------------------------
    import java.sql.*;
    public class testConnection{
    public static void main(String args[]) throws SQLException {
    String IPAddress = "10.80.50.202"; //IPAddress of server where DB2 is installed
    String portNum = "50002"; //Port Number at which DB2 server is running.
    String database = "fcdemo";//Database name
    String url = "jdbc:db2://"+IPAddress+":"+portNum+"/"+database;
    String user = "db2usr";
    String password = "pwd1234";

    DriverManager.registerDriver(new com.ibm.db2.jcc.DB2Driver());
    Connection conn = DriverManager.getConnection(url,user,password);
    System.out.println("Conn:"+conn);
    }
    }
    --------------------------------------------------
    Good Luck!!

  5. #5
    Join Date
    Mar 2004
    Posts
    5
    I got this while trying to compile



    java.lang.Error: Unresolved compilation problem:
    com.ibm.db2.jcc.DB2Driver cannot be resolved or is not a type

    at ConnectTest.main(ConnectTest.java:30)
    Exception in thread "main"


    DB2 is on the same computer as the one i'm trying to run the Java app from.

Posting Permissions

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