trying to connect a bluemix app (java liberty profile) to our on-premise db/as400 using a secure gateway. Denying or allowing all connection, doesn\'t change the error message.
Reading your logs, the error message
Connection refused
is meaning that the Driver is working fine, but there is a connection issue and in your case, using the Secure Gateway, you should investigate both the AS400 server and the Secure gateway instance
Updating based on further discussion in comments.
Getting empty reply from server
on your cURL command to the cloud host:port should be generating logs on your SG Client. It should be the equivalent of a successful connection due to how a database would respond to this sort of connection.
This seems to narrow down the issue to how the request is being created in your Bluemix app. Another comment on the initial question suggests that your driver only accepts select ports as input, so the issue might originate there.
The JT400 JDBC driver communicates with the IBM i system using the IBM i Host Servers, which each run on different ports. You will need to forward all of these ports through your secure gateway in order for it to work. See this doc for more info (you'll need as-database, as-central, and as-signon at a minimum).
If you need to change the ports used by the app to connect, you can do so by creating an AS400 object and using setServicePort to change the default ports. Then pass the AS400 object to connect instead of using the system, user name, and password.