There are three different connection types to DB2 from batch : TSO Background (DSN), Call Attach (CAF), and Recoverable Resource Manager Services attachment facility (RRSAF).
DSN is the most common because IBM uses DSN in most examples. Abends are obscured with this method makes resolving debugging difficult. Extra DD statements are required to support batch TSO. Below is an example job step :
//DSNTEP2 EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
RUN PROGRAM(DSNTEP2) PLAN(DSNTEP91)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
CAF is the second most common and attachment to DB2 is performed within the programming by calling DB2 supplied routines and passing DB2 subsystem and plan name information. Clients usually create an installation specific routine and pass this information using a PARM statement or input DD. A program using CAF is called using PGM= within JCL like most other batch routines.
RRSAF is the newest connection type and the most robust. It requires that RRS be active on the LPAR. Like CAF, clients usually create an installation specific routine and pass this information using a PARM statement or input DD and the program called using PGM= within JCL like most other batch routines.