Mysql connection object
is there a way of checking that a mysql connection is open before i try to run a query through it?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Lalit MRank #1,186 · 1.5K reputationPosted Jan 8, 2010, 8:24 PM EST
http://www.weberdev.com/get_example-138.html
patrickRank #4,458 · 342 reputationPosted Jan 9, 2010, 6:13 PM EST
if(mysqlConnection==isOpen){execute}
else {
mysqlConnection.open();
execute
}
But theres no mysqlConnection==isOpen command - so I need to know how to do this
The point of this is i want to use the same connection in a singleton pattern rather than instantiate and open/close connections
patrickRank #4,458 · 342 reputationPosted Jan 10, 2010, 6:38 AM EST
if (Connection.State == ConnectionState.Closed)
{ Connection.Open(); }
else if (Connection.State == ConnectionState.Broken)
{ Connection.Close();
Connection.Open(); }