By submitting my Email address I confirm that I have read and accepted the Terms of Use and Declaration of Consent.

By submitting your personal information, you agree to receive emails regarding relevant products and special offers from TechTarget and its partners. You also agree that your personal information may be transferred and processed in the United States, and that you have read and agree to the Terms of Use and the Privacy Policy.

box. This would need to be a synchronous connection. How could I do it?

There are several common ways to call an RPG program from Java:

1. Use a DB2/400 Stored procedure call.

2. Create a Program Call Object in the Java Toolkit for AS/400 using PDML.

3. Use JNI ( Java Native Interface ) to call an ILE RPG program.

There are advantages and disadvantages to each. Only the stored procedure can return a result set if needed. JNI is an process call.

Usually we use stored procedure calls for calling RPG programs from Java.

You need to have the jt400.jar file in the Java classpath so you can access the JDBC driver class needed for remote SQL access to the AS/400:

com.ibm.as400.access.AS400JDBCDriver

This works on any platform a JSDK will run on including iSeries. It has the most flexibility in how to call your RPG program.

1. Create a stored procedure on the AS/400 to call your RPG program. You can pass in parameters. Receive back updated parameters from your RPG program. If needed, you could even return a result set that your Java client could navigate a row at a time !

2. Use AS/400 Java toolkit JDBC Driver to run the remote stored procedure on the AS/400.

Open a JDBC connection. Create an SQL CALL statement to call the stored procedure passing parms as needed. Receive the updated parms from the call. Close the statement and the connection.

Here is an example of a stored procedure definition to call a CL program passing in 2 variables and returning 2 variables:

The statement above can be run in either Interactive SQL on the iSeries or (as I prefer) in a JDBC SQL statement to create the procedure definition.

Having created the procedure, you run a CALL statement to execute it. Here I use the following string in a prepared statement to run the procedure. Before executing the statement, I can set the first 2 input parameter Values, which are passed to my host CL program.

String stmt = "CALL CCBS.EMPGC01C (?, ?, ?, ?)";

The REALLY good news from IBM. If you don't know how to do the SQL above in Java you can use 2 IBM visual tools to: create the procedure and call it.

DB2/400 stored procedures can be defined in Operations Navigator.

You can create a call to a stored procedure as an SQL Call Statement in WebSphere Studio visually. You can also generate a JSP application to run the stored procedure visually using the WebSphere Studio database wizard.

0 comments

E-Mail

Username / Password

Password

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy