Disconnecting from data sources in JDBC applications
When you have finished with a connection to a data source, it is essential that you close the connection to the data source. Doing this releases the Connection object's database and JDBC resources immediately.
Procedure
Connection con;
…
con.close();
For a connection to a Db2 data source, if autocommit mode is not on, the connection needs to be on a unit-of-work boundary before you close the connection.
For a connection to an IBM® Informix® database, if the database supports logging, and autocommit mode is not on, the connection needs to be on a unit-of-work boundary before you close the connection.
For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on Db2 for z/OS®, when you close the connection to a data source, the driver issues an implicit rollback to ensure consistency of the underlying RRSAF thread before thread termination.