Overview: How CICS connects to Db2
A CICS® Db2® attachment facility is provided with CICS. The CICS Db2 attachment facility provides CICS applications with access to Db2 data while operating in the CICS environment.
CICS coordinates recovery of both Db2 and CICS data if transaction or system failure occurs.
The CICS Db2 attachment facility creates an overall connection between CICS and Db2. CICS applications use this connection to issue commands and requests to Db2. The connection between CICS and Db2 can be created or terminated at any time, and CICS and Db2 can be started and stopped independently. You can name an individual Db2 subsystem to which CICS connects, or (if you have DB2® Version 7 or later) you can use the group attach facility to let Db2 choose any active member of a data-sharing group of Db2 subsystems for the connection. You also have the option of CICS automatically connecting and reconnecting to Db2. A Db2 system can be shared by several CICS systems, but each CICS system can be connected to only one Db2 subsystem at a time.
You define the CICS Db2 connection using three different CICS resource definitions: DB2CONN (the Db2 connection definition), DB2ENTRY (the Db2 entry definition), and DB2TRAN (the Db2 transaction definition). You must install a DB2CONN resource definition before you can start the CICS Db2 connection. (Do not confuse this resource definition with the DB2CONN system initialization parameter, which specifies whether you want CICS to start the Db2 connection automatically during initialization.) You can also create DB2ENTRY and, if necessary, DB2TRAN definitions to ensure that your important transactions are prioritized. Overview: How you can define the CICS Db2 connection has more information about these resource definitions.
- STRT - start the connection to Db2
- STOP - stop the connection to Db2
- DISP - display the status of threads, and display statistics
- MODI - modify characteristics of the connection to Db2
- DISC - disconnect threads
The connection between CICS and Db2 is a multithread connection. Within the overall connection between CICS and Db2, there is a thread—an individual connection into Db2—for each active CICS transaction accessing Db2. Threads allow each CICS transaction to access Db2 resources, such as a command processor or an application plan (the information that tells Db2 what the application program's SQL requests are, and the most efficient way to service them). See Overview: How threads work for a full explanation of how threads work.
- A language interface, or stub, DSNCLI, that is link-edited with the application program calls the CICS resource manager interface (RMI).
- The RMI processes the request, and passes control to the CICS Db2 attachment facility's task-related user exit (TRUE), the module that invokes Db2 for each task.
- The CICS Db2 attachment facility schedules a thread for the transaction. At this stage, Db2 checks authorization, and locates the correct application plan.
- Db2 takes control, and the CICS Db2 attachment facility waits while Db2 services the request.
- When the SQL request completes, Db2 passes the requested data back to the CICS Db2 attachment facility.
- CICS now regains control, and the CICS Db2 attachment facility passes the data and returns control to the CICS application program.