Home | Previous Page | Next Page   Connecting to the Database >

Closing the Connection

The following table contrasts the different effects of calling the Connection.close() and scrubConnection() methods in environments that use connection pooling and those that do not.

For more information on deallocating resources, see Deallocating Resources. For more information on the scrubConnection() method, see Cleaning Pooled Connections.

Connection Pooling Status Effect of Calling Connection.close() Method Effect of Calling scrubConnection() Method
Non-connection pool setup Closes database connection, all associated statement objects, and their result sets Connection is no longer valid. Returns connection to original state, keeps opened statements, but closes result sets Connection is still valid.
Releases resources associated with result sets only.
Connection pool with Informix Implementation Closes connection to the database and reopens it to close any statements associated with the connection object and reset the connection to its original state Connection object is then returned to the connection pool and is available when requested by a new application connection. Returns a connection to original state and keeps all open statements, but closes all result sets
Calling this method in this situation not recommended
Connection pool with application server implementation Defined by your connection pooling implementation Returns connection to original state and retains opened statements, but closes result sets
This functionality can be useful if you are using the JDBC 3.0 feature of statement pooling with connections. When your application calls the Connection.close() method, your application server's connection-pool manager can call scrubConnection() for the pooled connection object before returning the object to the connection pool.

Important:
When calling the scrubConnection() method, your applications should be using server-only connections.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]