This sample demonstrates a Spring Boot JDBC application that connects to IBM Db2 for z/OS using two simultaneous DataSources — one using JDBC type 2 (native z/OS) connectivity, and one using JDBC type 4 (TCP/IP) connectivity. The application is deployed to a CICS Liberty JVM server and uses the Db2 employee sample table (EMP).
Key Features:
- Multiple Spring
DataSourcebeans wired via JNDI from Libertyserver.xml - REST endpoints routed by connection type (
/type2/...and/type4/...) - Global (XA) transaction support via Spring
@Transactional— coordinates CICS UOW with Db2 - Full CRUD operations: list, add, update, delete employees
- Supports CICS Bundle Plugin deployment (Gradle and Maven) and direct WAR deployment
- Overview
- Prerequisites
- Downloading
- Check dependencies
- Building the Sample
- Deploying to a CICS Liberty JVM server
- Running the Sample
- Troubleshooting
- License
- Additional Resources
- Contributing
- CICS TS V6.1 or later
- A configured Liberty JVM server in CICS
- Java SE 17 or later on the workstation
- IBM Db2 for z/OS V13 or later with the
EMPsample table - A CICS DB2CONN resource installed and connected (for type 2 connectivity)
- Either Gradle or Apache Maven on the workstation (optional — wrappers are provided)
- Eclipse with IBM CICS Explorer SDK (optional — for Eclipse import and bundle export)
Clone the repository using your IDE's Git support, or download as a ZIP:
git clone https://github.com/cicsdev/cics-java-liberty-springboot-jdbc-multi.gitTip: Eclipse Git provides an Import existing Projects checkbox when cloning a repository.
Add the following features to your Liberty server.xml:
<featureManager>
<feature>servlet-6.0</feature>
<feature>jdbc-4.3</feature>
<feature>transportSecurity-1.0</feature>
</featureManager>Note:
cicsts:core-1.0(and thetransaction-2.0it provides) is automatically injected by CICS in integrated Liberty mode — you do not need to add it.
Add two dataSource definitions — one for type 2 and one for type 4 connectivity. A sample server.xml is provided in etc/config/liberty/server.xml. Substitute your Db2 connection details before deploying.
You can build using Gradle or Maven from the command line, or using Eclipse.
./gradlew clean build./mvnw clean verifyThe WAR file is produced at:
- Gradle:
cics-java-liberty-springboot-jdbc-multi-app/build/libs/cics-java-liberty-springboot-jdbc-multi.war - Maven:
cics-java-liberty-springboot-jdbc-multi-app/target/cics-java-liberty-springboot-jdbc-multi.war
- Git Repositories view → right-click Working Tree → Import Projects (imports root)
- Switch to Java EE perspective
- Right-click
cics-java-liberty-springboot-jdbc-multi-app→ Import Projects - Right-click
cics-java-liberty-springboot-jdbc-multi-cicsbundle→ Import Projects - Right-click
cics-java-liberty-springboot-jdbc-multi-cicsbundle-eclipse→ Import Projects - Right-click root project → Gradle → Refresh Gradle Project (or Maven → Update Project)
Note: If you see compile errors after import, run a Gradle Refresh or Maven Update — this resolves the Spring Boot dependencies on the classpath.
Build the CICS bundle ZIP using the CICS Bundle Plugin:
./gradlew clean build
./mvnw clean verifyThe bundle ZIP is produced at:
- Gradle:
cics-java-liberty-springboot-jdbc-multi-cicsbundle/build/distributions/cics-java-liberty-springboot-jdbc-multi-cicsbundle-1.0.0.zip - Maven:
cics-java-liberty-springboot-jdbc-multi-cicsbundle/target/cics-java-liberty-springboot-jdbc-multi-cicsbundle-1.0.0.zip
Upload the ZIP to zFS and define a CICS BUNDLE resource pointing to the extracted directory.
- In Eclipse, import all projects as described in Building the Sample
- Right-click
cics-java-liberty-springboot-jdbc-multi-cicsbundle-eclipse→ Export Bundle Project to z/OS UNIX File System - Follow the wizard to transfer the bundle to your z/OS system
- Install and enable the CICS BUNDLE resource
- Build the WAR using Gradle or Maven as above
- Upload
cics-java-liberty-springboot-jdbc-multi.warto a directory on zFS (e.g.${server.config.dir}/springapps/) - Add the following
<application>element to your Libertyserver.xml:
<application id="cics-java-liberty-springboot-jdbc-multi"
location="${server.config.dir}/springapps/cics-java-liberty-springboot-jdbc-multi.war"
name="cics-java-liberty-springboot-jdbc-multi"
type="war">
<application-bnd>
<security-role name="cicsAllAuthenticated">
<special-subject type="ALL_AUTHENTICATED_USERS"/>
</security-role>
</application-bnd>
</application>- Also add the two
dataSourcedefinitions frometc/config/liberty/server.xmlwith your Db2 connection details
Verify the application started successfully by checking for message CWWKT0016I in messages.log:
CWWKT0016I: Web application available (default_host): http://myzos.mycompany.com:httpPort/cics-java-liberty-springboot-jdbc-multi
Then access the root endpoint in your browser — it will prompt for basic authentication (use your RACF userid and password):
http://myzos.mycompany.com:httpPort/cics-java-liberty-springboot-jdbc-multi/
This returns a usage page listing all available endpoints. Example requests:
| Operation | Type 2 (native z/OS) | Type 4 (TCP/IP) |
|---|---|---|
| List all employees | /type2/allEmployees |
/type4/allEmployees |
| List one employee | /type2/listEmployee/{empno} |
/type4/listEmployee/{empno} |
| Add employee | /type2/addEmployee/{first}/{last} |
/type4/addEmployee/{first}/{last} |
| Add (XA transaction) | /type2/addEmployeeTx/{first}/{last} |
/type4/addEmployeeTx/{first}/{last} |
| Delete employee | /type2/deleteEmployee/{empNo} |
/type4/deleteEmployee/{empNo} |
| Update salary | /type2/updateEmployee/{empNo}/{salary} |
/type4/updateEmployee/{empNo}/{salary} |
Note: Ensure your CICS DB2CONN resource is installed and connected before testing type 2 endpoints.
Application fails to start — CWWKZ0014W: application could not be found
The location in server.xml does not match where you uploaded the WAR. Update the location attribute to the actual zFS path.
JNDI lookup failed for jdbc/t2DataSource or jdbc/t4DataSource
The dataSource definitions are missing from server.xml. Add both dataSource elements from etc/config/liberty/server.xml with your Db2 connection details.
Type 2 update operations roll back unexpectedly
This is expected behaviour — the Liberty connection manager rolls back T2 connections on close when not in a global transaction. Use the ...Tx endpoints (e.g. /type2/addEmployeeTx) to wrap operations in a global XA transaction and get consistent commit behaviour across both DataSources.
CWWKS9112W or authentication errors
Ensure cicsts:security-1.0 is in your featureManager and your RACF user has the cicsAllAuthenticated security role.
This project is licensed under the Eclipse Public License - v 2.0.
- CICS and JDBC documentation
- Developing Spring Boot applications for CICS
- CICS Bundle Maven Plugin
- CICS Bundle Gradle Plugin
This sample is maintained by IBM CICS development. We welcome bug reports and feature requests via GitHub Issues. Contributions are welcome and reviewed on a case-by-case basis — please read the contributing guidelines before opening a pull request. For CICS product questions, contact IBM Support.