Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2013
    Posts
    3

    Unanswered: JDBC DB2 Connection does not respond

    Hi,

    I am trying to connect IBM Mainframe DB2 8.1 database using Eclipse
    application class through JDBC db2 type 4 universal driver. this is the
    following code of the DB2Connection.java

    import java.sql.Connection;
    import java.sql.SQLException;

    public class DB2Connection {

    public static void main(String[] argv) {

    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rset=null;
    boolean found=false;

    try {

    Class.forName("com.ibm.db2.jcc.DB2Driver");
    System.out.println("DB2 driver is loaded successfully");
    conn = DriverManager.getConnection("jdbc:db2://220.227.139.118:23
    /TWSDB","tws0001","mar2013");
    if (conn != null)
    {
    System.out.println("DB2 Database Connected");
    }else{
    System.out.println("Db2 connection Failed ");
    }
    } catch (Exception e) {
    System.out.println("DB2 Database connection Failed");
    e.printStackTrace();
    }finally{
    try {
    if(conn!=null){
    conn.close();
    }
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }
    }

    DB2 driver is loaded successfully

    after the above message

    I got the following exception

    DB2 Database connection Failed
    com.ibm.db2.jcc.am.yn: [jcc][t4][2030][11211][3.57.82] A communication error occurred during operations on the connection's underlying socket, socket input stream,
    or socket output stream. Error location: Reply.fill(). Message: Read timed out. ERRORCODE=-4499, SQLSTATE=08001
    at com.ibm.db2.jcc.am.bd.a(bd.java:319)
    at com.ibm.db2.jcc.t4.a.a(a.java:365)
    at com.ibm.db2.jcc.t4.a.a(a.java:360)
    at com.ibm.db2.jcc.t4.ab.b(ab.java:202)
    at com.ibm.db2.jcc.t4.ab.c(ab.java:243)
    at com.ibm.db2.jcc.t4.ab.c(ab.java:354)
    at com.ibm.db2.jcc.t4.ab.v(ab.java:1139)
    at com.ibm.db2.jcc.t4.bb.a(bb.java:42)
    at com.ibm.db2.jcc.t4.b.m(b.java:1240)
    at com.ibm.db2.jcc.t4.b.b(b.java:1114)
    at com.ibm.db2.jcc.t4.b.c(b.java:701)
    at com.ibm.db2.jcc.t4.b.b(b.java:687)
    at com.ibm.db2.jcc.t4.b.a(b.java:374)
    at com.ibm.db2.jcc.t4.b.<init>(b.java:310)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection( DB2SimpleDataSource.java:214)
    at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:2 24)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.ford.gaps.dao.DB2Connection.main(DB2Connection .java:34)
    Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at com.ibm.db2.jcc.t4.ab.b(ab.java:195)
    ... 15 more

    I closed the connection properly in the finally block,so some other thing
    that would not allow to connect DB2 on mainframe.

    Can anybody share your points here?

    Thanks and regards,
    Ramesh K

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    is the db2 listening to these connections/port
    has DB2/ddf been configured for external connections ?
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Apr 2013
    Posts
    3
    The DB2 8.1 Database could be accessed by HATS Mainframe application
    and in main.hco HATS configuration file.

    But I do not know about the access of the external connections.

    How do we set the mainframe DB2 to accept external connections like
    from jdbc call.

  4. #4
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  5. #5
    Join Date
    Nov 2012
    Posts
    6

    Miss port number

    "jdbc:db2://<server name>: <portnumber>/<database name>";

    This is the correct syntax. I don't see in the log you posted the port number

  6. #6
    Join Date
    Apr 2013
    Posts
    3

    I gave the correct syntax as you specified

    conn = DriverManager.getConnection("jdbc:db2://220.227.139.118:23
    /TWSDB","tws0001","mar2013");

    here 23 is the port number

  7. #7
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    is 23 not a reserved port for telnet/ssh
    usually db2 is listening to a much higher port
    I don't know the default for Z/db2 (437 ??)
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Posting Permissions

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