如何将bluemix应用程序连接到内部部署db / as400?

时间:2016-06-06 14:29:31

标签: db2 ibm-cloud ibm-midrange db2-400 secure-gateway

尝试使用安全网关将bluemix应用程序(java自由配置文件)连接到我们的内部部署db / as400。拒绝或允许所有连接,不会更改错误消息。似乎来自应用程序的请求没有到达安全网关客户端(我没有在sgw客户端上看到提及连接被拒绝的消息)。

我该如何解决?这段代码:

    DB_SERVERNAME=jdbc:as400://xxx-xx-xxx-x.integration.ibmcloud.com:15XXX/dbname

    try {
                Driver driver = new com.ibm.as400.access.AS400JDBCDriver();
                DriverManager.registerDriver(driver);
                System.out.println("Driver Loaded Successfully ...");
                dbConn = DriverManager.getConnection(DB_SERVERNAME, DB_USERNAME, DB_PASSWORD);
                System.out.println("Connected...");
            }   catch (SQLException e) {                
                e.printStackTrace();

            } 

错误消息是:

Driver Loaded Successfully ...
ERR App [err] java.sql.SQLException: The application requester cannot establish the connection. (Connection refused)
ERR App [err]   at com.ibm.as400.access.JDError.throwSQLException(JDError.java:565)
ERR App [err]   at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3308)
ERR App [err]   at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1393)
ERR App [err]   at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1230)
ERR App [err]   at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:371)
ERR App [err]   at java.sql.DriverManager.getConnection(Unknown Source)
ERR App [err]   at java.sql.DriverManager.getConnection(Unknown Source)
ERR App [err]   at wasdev.sample.servlet.DBServlet.getDBConnection(DBServlet.java:106)
ERR App [err]   at wasdev.sample.servlet.DBServlet.doGet(DBServlet.java:64)
ERR App [err]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
ERR App [err]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
ERR App [err]   at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1290)
ERR App [err]   at [internal classes]
ERR App [err]   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
ERR App [err]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
ERR App [err]   at java.lang.Thread.run(Unknown Source)
ERR App [err] Caused by:
ERR App [err] java.net.ConnectException: Connection refused
ERR App [err]   at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
ERR App [err]   at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
ERR App [err]   at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
ERR App [err]   at java.net.SocksSocketImpl.connect(Unknown Source)
ERR App [err]   at java.net.Socket.connect(Unknown Source)
ERR App [err]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
ERR App [err]   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
ERR App [err]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
ERR App [err]   at java.lang.reflect.Method.invoke(Unknown Source)
App [err]   at com.ibm.as400.access.PortMapper.getSocketConnection(PortMapper.java:273)
ERR App [err]   at com.ibm.as400.access.PortMapper.getServerSocket(PortMapper.java:161)
ERR App [err]   at com.ibm.as400.access.AS400ImplRemote.signonConnect(AS400ImplRemote.java:2334)
ERR App [err]   at com.ibm.as400.access.AS400ImplRemote.signon(AS400ImplRemote.java:2250)
ERR App [err]   at com.ibm.as400.access.AS400.sendSignonRequest(AS400.java:3035)
ERR App [err]   at com.ibm.as400.access.AS400.signon(AS400.java:3910)
ERR App [err]   at com.ibm.as400.access.AS400.connectService(AS400.java:1168)
ERR App [err]   at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3300)
ERR App [err]   ... 32 more

3 个答案:

答案 0 :(得分:0)

根据评论中的进一步讨论进行更新。

在您的cURL命令上获取empty reply from server到云主机:端口应该在您的SG客户端上生成日志。由于数据库如何响应这种连接,它应该等同于成功的连接。

这似乎将问题缩小到如何在您的Bluemix应用程序中创建请求。对初始问题的另一个评论表明,您的驱动程序只接受选择端口作为输入,因此问题可能源自那里。

答案 1 :(得分:0)

阅读您的日志,错误消息

  

拒绝连接

意味着驱动程序工作正常,但存在连接问题,在您的情况下,使用Secure Gateway,您应该调查AS400服务器和安全网关实例

  • #1是在Secure Gateway实例上正确映射的TCP端口15XXX(试图通过JDBC url之后的驱动程序连接)
  • #2a如果#1为真,AS400服务器是否在同一TCP端口上侦听传入连接?
  • #2b如果#2a为false,AS400服务器是否在另一个TCP端口上侦听?
  • #3根据AS400服务器(#2a或#2b)监听的TCP端口,此端口在Secure Gateway实例上正确映射,允许通过Secure Gateway发送到TCP 15XXX的请求正确路由到AS400服务器上的右端口?
  • #4如果#3为真,AS400服务器是否有防止传入连接的内部防火墙?

答案 2 :(得分:0)

JT400 JDBC驱动程序使用IBM i Host Servers与IBM i系统进行通信,this分别在不同的端口上运行。您需要通过安全网关转发所有这些端口才能使其正常工作。有关详细信息,请参阅setServicePort doc(您​​至少需要as-database,as-central和as-signon)。

如果您需要更改应用程序用于连接的端口,可以通过创建AS400对象并使用analyzed strings更改默认端口来实现。然后传递AS400对象进行连接,而不是使用系统,用户名和密码。