Connecting to db2/400 of AS400 through java throwing SQLException

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

  1. savita

    savita Guest

    Hello,

    I am trying to connect to db2/400 of as400 through java in WDSC.
    I am usinf the driver ->
    com.ibm.db2.jcc.DB2Driver
    I have put the db2jcc.jar and db2jcc_license_c.jar in classpath.

    I am not ableto connect with db2/400
    The code for connecting to the database is follows-->

    ******************************************************************************
    //Connect to a database
    try
    {
    Connection conn = DriverManager.getConnection
    ("jdbc:db2:192.168.0.10","SAVITA","SAVITA");
    }
    catch (SQLException e)
    {
    System.out.println("SQL Exception: ");
    }
    *******************************************************************************
    I am getting the following run time error
    SQL Exception
    .....................................................................................................
    Do I have to use other url apart from jdbc:db2:192.168.0.10

    I have used jdbc:db2:S650B66E

    where S650B66E=system name
    In the actual code instead of 192.168.0.10 they have used databasename.
    My requirement is , to call stored procedure from db2/400 of as400.
    Firstly how do I connect to db2/400?
    Can please any body help me out.
    Thanks
    Regards
    Savita
     
    savita, Dec 29, 2006
    #1
    1. Advertising

  2. savita wrote:
    > I am trying to connect to db2/400 of as400 through java in WDSC.
    > I am usinf the driver ->
    > com.ibm.db2.jcc.DB2Driver
    > I have put the db2jcc.jar and db2jcc_license_c.jar in classpath.


    > //Connect to a database
    > try
    > {
    > Connection conn = DriverManager.getConnection
    > ("jdbc:db2:192.168.0.10","SAVITA","SAVITA");
    > }
    > catch (SQLException e)
    > {
    > System.out.println("SQL Exception: ");


    I strongly recommend you to print out e.

    > }
    > *******************************************************************************
    > I am getting the following run time error
    > SQL Exception
    > ....................................................................................................
    > Do I have to use other url apart from jdbc:db2:192.168.0.10
    >
    > I have used jdbc:db2:S650B66E
    >
    > where S650B66E=system name


    This should be in the DB2 JDBC docs.

    I use a URL syntax like:

    Connection con =
    DriverManager.getConnection("jdbc:db2://localhost:50000/xxxx", "xxxx",
    "xxxx");

    where xxxx is database, username and password.

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

  3. savita

    Lew Guest

    savita wrote:
    >> Do I have to use other url apart from jdbc:db2:192.168.0.10


    Arne Vajhøj wrote:
    > This should be in the DB2 JDBC docs.


    E.g.,
    <http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/cjvjt2cn.htm>

    "Syntax for a URL for the DB2 JDBC Type 2 Driver:
    jdbc:db2:database

    "database
    A database alias. The alias refers to the DB2 database catalog entry on the
    DB2 client."

    This is for the case where there is a database catalog and a Type 2 driver.

    Arne Vajhøj wrote:
    > I use a URL syntax like:
    >
    > Connection con =
    > DriverManager.getConnection("jdbc:db2://localhost:50000/xxxx", "xxxx",
    > "xxxx");
    >
    > where xxxx is database, username and password.


    From
    <http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0504vohra/index.html>

    "The format of the DB2 JDBC Type 4 driver is jdbc:db2://<server>:<port>/<da...es I turned up googling around a bit. - Lew
     
    Lew, Dec 30, 2006
    #3
  4. Lew wrote:
    > <http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/cjvjt2cn.htm>
    >
    >
    > "Syntax for a URL for the DB2 JDBC Type 2 Driver:
    > jdbc:db2:database


    > <http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0504vohra/index.html>
    >
    > "The format of the DB2 JDBC Type 4 driver is > jdbc:db2://<server>:<port>/<...ows the type 4 jar file and class name. Arne
     
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Dec 30, 2006
    #4
  5. savita

    Lew Guest

    Arne Vajhøj wrote:
    > The original post shows the type 4 jar file and class name.


    The point being that perhaps use of the Type 2 syntax was not correct, eh?

    - Lew
     
    Lew, Dec 30, 2006
    #5
    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. =?Utf-8?B?RC5TYXJhdmFuYW4=?=

    DB_E_BADPROPERTYVALUE error when connecting to AS400 db2 udb

    =?Utf-8?B?RC5TYXJhdmFuYW4=?=, Jun 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    506
    =?Utf-8?B?RC5TYXJhdmFuYW4=?=
    Jun 18, 2004
  2. Replies:
    0
    Views:
    7,678
  3. savita
    Replies:
    1
    Views:
    1,623
  4. savita
    Replies:
    9
    Views:
    4,498
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Jan 5, 2007
  5. Biegster

    Connecting Unix to iSeries AS/400 DB2

    Biegster, Jul 8, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    113
    dominix
    Jul 12, 2003
Loading...

Share This Page