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

不打扰是莪最后的温柔 提交于 2019-12-10 17:20:01

问题


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)


回答1:


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).




回答2:


I had the same issue. and spend around 4 hour then the below solution worked for me :

Project Explorer -> Server - > Tomcat v X.X -> open server.xml

<Connector port="8484" protocol="AJP/1.3" redirectPort="8484 "/>

I change my port and redirectPort with the same port number which I assign to server i.e.8080 or 8484.

Hope this will work.



来源:https://stackoverflow.com/questions/31866614/i-am-getting-operation-timed-out-errorcode-4499-sqlstate-08001-connecting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!