JDBC DB2 Connection does not respond

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
Ramesh Kangamuthu
Member
Posts: 1
Joined: Thu Apr 04, 2013 10:36 am

JDBC DB2 Connection does not respond

Post by Ramesh Kangamuthu » Thu Apr 04, 2013 10:40 am

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.

I added the db2 jdbc jars on the classpath

1) db2jcc.jar

2) db2jcc_license_cisuz.jar

3) db2jcc_license_cu.jar

Can anybody share your points here?

Thanks and regards,
Ramesh K

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Thu Apr 04, 2013 5:13 pm

Please do not post the same question on multiple forums at once. It is bad manners and does not get you a response any quicker - it may even be slower. Also, you are presenting your companies IP address to a wider audience.

Your other copy that I found has been locked.
Regards
Nic

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others