DB2 10.5 for Linux, UNIX, and Windows

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

To close the connection to the data source, use the close method.
For example:
 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.