When using the DB2 JDBC Driver db2jcc on z/OS with type 2 connectivity, running connections to the database will commit its transactions, while the JVM is terminating. This may or may not be the wanted behavior, but this is the default. However, you are able to change this behavior.
To do so you either have to place a file named DB2JccConfiguration.properties in your classpath or you specify a different filename by adding the following VM argument to your java call:
-Ddb2.jcc.propertiesFile=C:/db2jcc.properties
In this file you have to add the following properties:
db2.jcc.promoteAbortToAbend=yes
db2.jcc.rollbackOnShutdown=true
Without the first property a canceled java process will still commit its remaining transactions, because its termination is considered normal. If set to yes or true, the cancel will be promoted to the abend state, which will lead to the action specifed by the second property.
With this property, the db2jcc driver registers a shutdown hook on JVM termination which disables all running connections. After this, no further statements will be accepted by any connection. Right after this the shutdown hook starts to rollback all transactions one by one.