To look up a previously-published connection factory in the JNDI namespace
used by CICS, use code such as the following:
// Declare a ConnectionFactory object
ConnectionFactory cf = null;
try{
// Get the initial JNDI context
javax.naming.Context ic = new javax.naming.InitialContext();
// Do the lookup, casting the returned CICSConnectionFactory to type
// ConnectionFactory
cf = (ConnectionFactory)ic.lookup("ConnectionFactory/CICSConnectionFactory");
// Use the connection factory to create a connection to CICS
Connection eciConn = (Connection)cf.getConnection();
}
catch (Exception e){
// Lookup failed, or specified connection factory has not been published
// Exception processing
}
This is illustrated in the CCI Connector application—see
The CCI Connector sample application.