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