home movie radio music chord lyrics book game Dictionary clip
HOME HAND MADE RADIO SHOP CHORD LYRICS BOOKS GAME Dictionary Clip
Previous Section  < Day Day Up >  Next Section

5.3 Closing a Database Connection

Once an application is finished using an open connection, that connection should be closed. Some APIs automatically close connections when the application exits; however, it is best to explicitly close the connection as soon as the application is finished accessing the database to allow other applications access to precious connection resources.

Calling the appropriate close methods when finished with an ADO.NET or JDBC object is essential to freeing precious database resources used by the application. Both ADO.NET and Java offer very few guarantees when objects are finalized; therefore, it is common for those applications that don't close objects explicitly to run out of database resources (such as connections, statement handles, and memory).


5.3.1 Closing an ADO.NET Database Connection

To close an ADO.NET connection, invoke the Close method on the connection object:

connection.Close( );

5.3.2 Closing a JDBC Database Connection

To close a JDBC connection, invoke the close method on the connection object:

connection.close( );

    Previous Section  < Day Day Up >  Next Section