MySQL Forums
Forum List  »  Newbie

Re: When to open/close the MySQLConnector
Posted by: Phillip Ward
Date: May 03, 2012 06:37AM

Remember that every page request is handled separately by the web server.
For every request, open a connection, use it and then close it when you're done with it. Connection pooling should take care of [most of] the overhead in establishing new connections.

Don't bother putting it into Session data (I won't even glorify "global" with a mention). If you do, then you first have to worry about whether it's actually present in the Session data (and create it if it isn't) and then worry about whether it's still in a usable state from when you last used it (which it might not be) and then you can finally get round to actually using it. You'll stay far saner if you keep things simple; stick to the Open, Use, Close model and handle any errors as and when they happen.

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: When to open/close the MySQLConnector
May 03, 2012 06:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.