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( ); 



SQL in a Nutshell
SQL in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596518846
EAN: 2147483647
Year: 2003
Pages: 78

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net