问题描述
我正尝试使用IBM Type 4 JDBC驱动程序连接到远程DB2。
这是我的配置:
I am attempting to connect to a remote DB2 using IBM Type 4 JDBC driver.Here is my configuration:
服务器:
- Windows 7专业
- DB2 LUW V10.5
- DB2 SVCENAME = 50000
- 要通信的TCP / IP li>
- Windows 7 professional
- DB2 LUW V10.5
- DB2 SVCENAME=50000
- TCP/IP to communicate
客户端:
- OS / x V10。 10.3
- Eclipse Mars
- IBM DB2 Java Type 4驱动程序
我的理解是,如果您使用Java编写客户端应用程序并使用类型为4的纯Java驱动程序,则客户端不必安装客户端。该应用程序将使用DRDA直接连接到远程数据库。
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.
以下是我尝试访问远程db2的一段代码片段:
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:
推荐答案
在许多情况下,服务器上的本地防火墙是一个问题。 Windows防火墙可能会阻止传入的请求。
In many cases the local firewall on the server is an issue. The Windows firewall could be blocking the incoming request.
您可以检查端口是否打开(防火墙报告的阻塞)?在DB2服务器的db2diag.log(诊断日志文件)中是否看到任何活动?作为一个快速测试,您可以从您的客户端机器执行telnet 192.168.1.81 50000。如果成功,并且连接了,那么防火墙不再是问题了。
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).
这篇关于我得到“操作超时。 ERRORCODE = -4499,SQLSTATE = 08001“连接到远程DB2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!