JDBC DB2 Connection does not respond



IBM's flagship relational database management system

JDBC DB2 Connection does not respond

Postby RameshK » Thu Apr 04, 2013 10:42 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
RameshK
 
Posts: 1
Joined: Thu Apr 04, 2013 10:35 am
Has thanked: 0 time
Been thanked: 0 time

Re: JDBC DB2 Connection does not respond

 

Re: JDBC DB2 Connection does not respond

Postby Robert Sample » Thu Apr 04, 2013 2:40 pm

I don't know JDBC but I do know you are attempting to connect on port 23, which is the default telnet port. The default JDBC port from what I can see is 1527, but I suspect that might vary depending upon which instance of DB2 you want to connect to. Your time out is probably because your program is not sending back telnet responses to the telnet port.

And did you change the IP address before posting so you did not expose your site's mainframe to the entire world?
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: JDBC DB2 Connection does not respond

Postby NicC » Thu Apr 04, 2013 5:42 pm

Multiple posting - locked.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post