JT400 - The JDBC connection is working fine when connecting to a IBMi machine from windows machine.
DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
String sysname = "xxx.xxx.xx.xxx";
String xref = "IBMISQLLIB";
String url = "jdbc:as400://" + sysname + ";translate binary=true;prompt=false;naming=sql;libraries=" + xref;
Connection connection = DriverManager.getConnection(url, "USERNAME", "PASSWORD");
print("Connection created successfully");
But fails to create the connection by using the same code - when running the code on the same IBMi machine (by a runnable jar on 'QSH Command Entry'), ERROR:
java.sql.SQLException: The application requester cannot establish the connection. (A remote host refused an attempted connect operation. (Connection refused)) at com.ibm.as400.access.JDError.createSQLExceptionSubClass(JDError.java:887) at com.ibm.as400.access.JDError.throwSQLException(JDError.java:610) at com.ibm.as400.access.JDError.throwSQLException(JDError.java:568) at com.ibm.as400.access.AS400JDBCConnectionImpl.setProperties(AS400JDBCConnectionImpl.java:3522) at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1430) at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1280) at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:403) at java.sql.DriverManager.getConnection(DriverManager.java:675) at java.sql.DriverManager.getConnection(DriverManager.java:258)
Any idea what is going wrong now ??
Some more details about the IBMi machine are:
The problem was related to default TCP/IP port, which was not listening the JDBC connection request.
And finally the problem got resolved by restarting the IBMi machine.
:)