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.
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 Dynamic Server 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.
Related concepts
“Example of a simple JDBC application” on page 7
“JDBC connection objects” on page 19
“How JDBC applications connect to a data source” on page 9
Related tasks
“Committing or rolling back JDBC transactions” on page 74
Chapter 3. JDBC application programming 99