COBOL call stub Java class usage example

The COBOL call stub Java™ class usage example shows how a batch application can invoke a COBOL procedure using the COBOL container.

In the example, the events take place in the following order:
  1. The COBOL container is created.
  2. The COBOL procedure call stub is created.
  3. The parameter data is set into the COBOL procedure call stub.
  4. A shared DB2® connection is set on the container.
  5. The COBOL procedure is invoked using the container.

Steps 1, 2 and 5 are the minimum steps required to invoke a COBOL procedure using the container. Steps 3 and 4 are optional. Step 3 is necessary only if the COBOL procedure receives parameters, and step 4 is necessary only if the COBOL procedure accesses DB2.

import com.ibm.websphere.batch.ilc.ILContainerFactory;
import com.ibm.websphere.batch.ilc.ILContainer;
import com.ibm.websphere.batch.ilc.ILContainerException;
import com.ibm.websphere.batch.ilc.ILProcedureException;

import com.ibm.ws.batch.ilc.sample.Sample;
import com.ibm.ws.batch.ilc.sample.parameters.SampleDataBinding;

import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.Connection;

try { 
// Create the container.
ILContainer container = ILContainerFactory.getFactory().create();

// Create target procedure using call stub.
Sample proc = new Sample();			

// Set parameters.
SampleDataBinding binding = proc.getSampleDataBinding();
	binding.setCDummy("foo");
	binding.setIlen((short)employeeNumber);
    
// Set db2 connection for use by COBOL (if necessary).
// InitialContext ic = new InitialContext();
// DataSource datasourceType2 = (DataSource) ic.lookup(jdbcJndi);
// Connection connectionType2 = datasourceType2.getConnection();
// container.setDB2Connection(connectionType2);			
	
	// Invoke the COBOL procedure.	
int rc = container.invokeProcedure(proc);
}
catch (ILProcedureException) {
…
}
catch (ILContainerException) {
…
}

指出主題類型的圖示 參照主題



時間戳記圖示 前次更新: July 9, 2016 11:12
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rgrid_using_javacall_stubs
檔名:rgrid_using_javacall_stubs.html