0

我们是三位开发人员,他们都使用 Netbeans 和 Java。一位开发人员可以很好地访问远程 DB2 服务器(使用相同的代码)。其他两个(包括我)不能。

这是 context.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/app_web">
    <Resource name="jdbc/admin"
              auth="Container"
              type="javax.sql.DataSource"
              maxActive="500"
              initialSize="10"
              maxIdle="50"
              maxWait="10000"
              username="theusername"
              password="xxxxxxxxx"
              driverClassName="com.ibm.as400.access.AS400JDBCDriver"
              removeAbandoned="true"
              removeAbandonedTimeout="60"
              logAbandoned="true"
              url="jdbc:as400://192.168.1.1;prompt=false;naming=system;prompt=false;naming=system;libraries=*libl;date format=iso;time format=iso"
              />

以下是我们得到的例外情况:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The application requester cannot establish the connection. (Permission denied: connect))
Caused by: java.sql.SQLException: The application requester cannot establish the connection. (Permission denied: connect)
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:528)
WARNING: Failed to register in JMX: javax.naming.NamingException: Cannot create PoolableConnectionFactory (The application requester cannot establish the connection. (Permission denied: connect))
WARNING: Unexpected exception resolving reference
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The application requester cannot establish the connection. (Permission denied: connect))
Caused by: java.sql.SQLException: The application requester cannot establish the connection. (Permission denied: connect)
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:528)
WARNING: Failed to register in JMX: javax.naming.NamingException: Cannot create PoolableConnectionFactory (The application requester cannot establish the connection. (Permission denied: connect))

我已将文件放入jt400.jar文件C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.35\lib夹,放入...\web\WEB-INF\lib文件夹等。似乎没有任何效果。

4

4 回答 4

1

日志中的消息Permission denied: connect让我认为这是一个 Java 策略问题。其他开发人员很可能配置了更宽松的 Java 策略。

请参阅http://docs.oracle.com/javase/6/docs/technotes/guides/security/PolicyFiles.html

于 2012-03-16T20:06:24.957 回答
1

我能够找到解决方案。显然,我必须在防火墙上打开端口 449。我以前看过那里,但由于这是一台公司机器,我没有发现配置了另一个防火墙(F-Secure)阻止它的事实。

于 2012-03-19T12:48:16.040 回答
0

我不确定 DB2,但是在某些数据库(例如 MySQL)中,您可以限制哪些 IP(客户端)可以连接到数据库,您确定这不是这样的问题吗?可能是已在数据库本身上设置的安全策略,仅允许某些 IP(包括您的合作伙伴的 IP)连接。

于 2012-03-16T20:21:24.750 回答
0

你们两个都使用同一个用户(用户名=“用户名”)连接吗?也许有一个与 IBM i(又名 AS/400)上的用户相关联的策略不允许多个连接

于 2012-03-16T22:53:33.283 回答