Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am getting " Operation timed out. ERRORCODE=-4499, SQLSTATE=08001" connecting to remote DB2

Tags:

db2

I am attempting to connect to a remote DB2 using IBM Type 4 JDBC driver. Here is my configuration:

Server:

  • Windows 7 professional
  • DB2 LUW V10.5
  • DB2 SVCENAME=50000
  • TCP/IP to communicate

Client:

  • OS/x V10.10.3
  • Eclipse Mars
  • IBM DB2 Java Type 4 drivers

It is my understanding that if you write the client app in Java and use the type 4—pure Java—drivers, the client doesn't have to have a client installed. The app will use DRDA to connect directly to the remote database.

Here is a snippet of code that I tried to access the remote db2:

public class BlobRetrieval {

    static String databaseDriver;
    static String dbURL;
    static String userName;
    static String password;
    static Connection passConn; 

public static void main(String[] args) {        
    databaseDriver = "com.ibm.db2.jcc.DB2Driver";
    dbURL = "jdbc:db2://192.168.1.81:50000/LOBDB";
    userName = "ace";
    password = "ace";
    try {
        Class.forName(databaseDriver).newInstance();
        System.out.println("register successful");
        Connection connection = DriverManager.getConnection(dbURL, userName, password);
        System.out.println("connection successful");
        passConn = connection;
        PreparedStatement preparedStatement=connection.prepareStatement("SELECT BOOKCOVER FROM BOOKCOVERS WHERE BOOKISBN=?");
        preparedStatement.setString(1, "0738425826");
    }
}

When I execute these statements, I get the following error:

register successful com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550] [4.19.26] Exception java.net.ConnectException: Error opening socket to server /192.168.1.81 on port 50,000 with message: Operation timed out. ERRORCODE=-4499, SQLSTATE=08001 at com.ibm.db2.jcc.am.kd.a(Unknown Source) at com.ibm.db2.jcc.am.kd.a(Unknown Source) at com.ibm.db2.jcc.t4.ac.a(Unknown Source) at com.ibm.db2.jcc.t4.ac.(Unknown Source) at com.ibm.db2.jcc.t4.a.b(Unknown Source) at com.ibm.db2.jcc.t4.b.newAgent_(Unknown Source) at com.ibm.db2.jcc.am.Connection.initConnection(Unknown Source) at com.ibm.db2.jcc.am.Connection.(Unknown Source) at com.ibm.db2.jcc.t4.b.(Unknown Source) at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(Unknown Source) at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(Unknown Source) at com.ibm.db2.jcc.DB2Driver.connect(Unknown Source) at com.ibm.db2.jcc.DB2Driver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at dbAccessPackage.BlobRetrieval.main(BlobRetrieval.java:30) Caused by: java.net.ConnectException: Operation timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at com.ibm.db2.jcc.t4.w.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method)

like image 648
Warren Mundy Jr Avatar asked Aug 06 '15 22:08

Warren Mundy Jr


1 Answers

In many cases the local firewall on the server is an issue. The Windows firewall could be blocking the incoming request.

Could you check that the port is open (any blocking reported by the firewall)? Is any activity seen in the "db2diag.log" (diagnostic log file) of the DB2 server? As a quick test you could do a "telnet 192.168.1.81 50000" from your client machine. If that succeeds and you got a connection, the firewall is not an issue (anymore).

like image 85
data_henrik Avatar answered Oct 13 '22 21:10

data_henrik