[TriLUG] mysql close statements

Ben Pitzer uncleben at mindspring.com
Fri Feb 20 15:29:41 EST 2004


In any case (I'm speaking for Perl, but I can't imagine it would be much
different in PHP, C, C++, Python, Ruby, Java, etc.), it's a good idea to
close the connection, just for the purposes of being thorough.  It's not
that much extra overhead to issue the close statement, and it makes sure to
avoid any potential locking issues, etc.  Even if it's just a 'select'
statement, depending on the library, a table or database could be locked by
the command while the query is run.  Without a close, that lock could remain
either until the lock times out, or forever, depending on the db in
question.  Most dbs will close or timeout locks after the accessing program
exits, and/or a timeout value is reached, but it's probably best not to
count on that, not to mention that until it does time out, or if the script
hangs and never exists, the lock remains in place.  I recommend it in just
about any event.

Regards,
Ben Pitzer

---------------------------------------------

"Those that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
 --Ben Franklin--




> -----Original Message-----
> From: trilug-bounces at trilug.org [mailto:trilug-bounces at trilug.org]On
> Behalf Of spain at ncssm.edu
> Sent: Friday, February 20, 2004 11:01 AM
> To: trilug at trilug.org; lug at lists.ncsu.edu
> Subject: [TriLUG] mysql close statements
>
>
> I just wanted to get a opinion from the masses on close statements for
> mysql..
>
> If you open a connection in an include file, run your query, and then
> display the results..
>
>  Is it necessary to include a mysql close connection statement? Or will
> these open connections you create close out eventually?  Does it have any
> effect on mysql server if you don't close out the connection?
>
>
>
>
>   _____
>
> Sincerely,
> Jamil Hassan Spain
> NC School of Science and Mathematics | External Programs
> Phone: 919-416-2641
> Web: www.dlt.ncssm.edu <http://www.dlt.ncssm.edu/>
> Email: spain at ncssm.edu <mailto:spain at ncssm.edu>
>   _____
>
>
>
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring         : http://trilug.org/~chrish/trilug.asc
>
>




More information about the TriLUG mailing list