lives
November 8th, 2001, 03:53 PM
hi all
if we make a connection Object as null will it close the connection?
rgds
Lives
if we make a connection Object as null will it close the connection?
rgds
Lives
| // JP opened flex table
Click to See Complete Forum and Search --> : JDBC lives November 8th, 2001, 03:53 PM hi all if we make a connection Object as null will it close the connection? rgds Lives poochi November 8th, 2001, 05:02 PM Here is what JDK 1.3 API documentation says about Connection.Close() method.. ----------------------------------- public void close() throws SQLException Releases a Connection's database and JDBC resources immediately instead of waiting for them to be automatically released. Note: A Connection is automatically closed when it is garbage collected. Certain fatal errors also result in a closed Connection. Throws: SQLException - if a database access error occurs -------------------------------- It answers your question. The best practice is , an object should release the resources it uses once it finish the job. In this case, you cant tell when the gc will run and when the connection will be closed. It is better to call close() method on connection object before you set it to null. Poochi.. codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved. |