Problem connecting to db2 through java in WDSC

Discussion in 'Java' started by savita, Dec 28, 2006.

  1. savita

    savita Guest

    Hello ,

    I want to connect to IBM db2400 of AS400 through java in websphere.
    The code I have written is follows


    package com.jdbc;


    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class Dbjdbc
    {
    public Dbjdbc()
    {


    }
    public static void main(String args[])
    {
    try
    {


    Class.forName("com.ibm.db2.jcc.DB2Driver");
    }
    catch (ClassNotFoundException e)
    {
    System.err.println("Could not load DB2 driver \n");
    System.err.println(e.getMessage());


    }


    try
    {
    //Connect to a database
    Connection conn = DriverManager.getConnection
    ("jdbc:db2:192.168.0.10","SAVITA","SAVITA");


    }
    catch (SQLException e)
    {
    System.out.println("SQL Exception: ");
    }
    }



    }


    I am getting compile error as follows:-

    ---------------------------------------------------------------------------­­---------------------------------------------------------



    Could not load DB2 driver


    com.ibm.db2.jcc.DB2Driver
    SQL Exception:
    ---------------------------------------------------------------------------­­----------------------------------------------------------



    Does it mean I have to install the DB2 Universal JDBC Driver
    com.ibm.db2.jcc.DB2Driver
    If yes? Please let me know the step to be followed.How to do ?


    Thanks
    Regards
    Savita
    savita, Dec 28, 2006
    #1
    1. Advertising

  2. savita wrote:
    > I want to connect to IBM db2400 of AS400 through java in websphere.
    > The code I have written is follows
    >


    > try
    > {
    >
    >
    > Class.forName("com.ibm.db2.jcc.DB2Driver");
    > }
    > catch (ClassNotFoundException e)
    > {
    > System.err.println("Could not load DB2 driver \n");
    > System.err.println(e.getMessage());
    >
    >
    > }
    >
    >
    > try
    > {
    > //Connect to a database
    > Connection conn = DriverManager.getConnection
    > ("jdbc:db2:192.168.0.10","SAVITA","SAVITA");
    >
    >
    > }
    > catch (SQLException e)
    > {
    > System.out.println("SQL Exception: ");
    > }
    > }
    >
    >
    >
    > }
    >
    >
    > I am getting compile error as follows:-


    No - you are getting a runtime error.

    > Could not load DB2 driver
    > com.ibm.db2.jcc.DB2Driver
    > SQL Exception:


    > Does it mean I have to install the DB2 Universal JDBC Driver
    > com.ibm.db2.jcc.DB2Driver
    > If yes? Please let me know the step to be followed.How to do ?


    You need to put the jar file(s) with the DB2 JDBC driver in
    your classpath.

    db2jcc.jar and db2jcc_license_something.jar

    Arne
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Dec 29, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moid
    Replies:
    1
    Views:
    483
  2. Replies:
    0
    Views:
    7,601
  3. savita
    Replies:
    4
    Views:
    4,035
  4. savita
    Replies:
    1
    Views:
    1,595
  5. Dinesh
    Replies:
    0
    Views:
    158
    Dinesh
    Apr 3, 2006
Loading...

Share This Page