I've searched through the site and haven't quite found a post that answers my problem.

I wrote a desktop application (Java/swing/JDBC) to connect to a local database via JDBC. This database is hosted on an IBM i-series (AS400) (though I'm quite certain this isn't an as400-only problem) and is only available on the internal network. I'm working on translating that application into an android app to be used onside in the warehouse via wireless connection.

I have my JDBC connection in it's own thread. The app asks the user for username/password before attempting a connection. The connection fails every time with the same message: java.sql.SQLException: The application requester cannot establish the connection. (No route to host)

Here is the offending code:

            try 
    {
        // Use the AS400 driver.
        DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
        // Now connect
        connection = DriverManager.getConnection(
                "jdbc:as400://" + IP_ADDRESS + "/" + SCHEMA + 
                ";naming=sql;errors=full",
                USER_ID, PASSWORD);
        System.out.println("Connection established using the AS400 driver(s)");
    }
    catch(Exception as400) 
    {
        String message = "Error setting driver and connection using\n " 
                +  "the AS400 drivers. The error message is as follows:\n " 
                +  as400.getMessage();
        System.out.println(message);
        throw new Exception(message);
    }

It registers the driver then hits No route to host, pauses for a second, then throws an error, completely stalling the device instead of letting my error handler safely close the app.

I have double (triple) checked to ensure the credentials are correctly passed and the IP and schema are both correctly set. This code is a direct copy of my desktop code. The only difference is I use a jar optimized for android instead of the desktop. The jar simply contains a translation layer between native AS400 code and Java, but works the same as any SQL jar.

This is our primary database server used throughout the entire company. It is always available and SQL is enabled on it. I am testing this using a physical android device (not an emulated one) and it is connected to our internal wireless network.

Any suggestions on how to fix this or even a direction to look in? Why is there such a difference between the desktop and my android despite both using JDBC? Do I need to do something special for address resolution or something similar? Google-fu is failing me badly. Thanks for your help!

有帮助吗?

解决方案

It's not uncommon for wireless traffic to be restricted due to corporate security policies.

Verify that you can connect to DRDA (tcp port 446) on the IBM i from the device on the wireless network.

See TCP/IP Ports Required for iSeries Access for Windows for more information.


JTOpen/Toolbox has a proxy mode if security requirements prevent allowing direct access to the IBM i.

Figure 1: How a standard client and a proxy client connect to a server

The lightweight version of the JTOpen/Toolbox jar's are also more suited to installation in a cpu and memory restricted environment such as an Android device.

Figure 2: Size comparison of proxy JAR files and standard JAR files

The full JTOpen/Toolbox can be run as a proxy server as follows:

java -cp jt400.jar com.ibm.as400.access.ProxyServer -verbose -port 3470

Add the proxy server option to your connection string:

jdbc:as400:<url>;proxy server=<proxy server address:port>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top