08001db2java程序,我得到“操作超时。 ERRORCODE = -4499,SQLSTATE = 08001“连接到远程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)

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值