Need help managing MySql connections

Posted by David Jenings on Stack Overflow See other posts from Stack Overflow or by David Jenings
Published on 2010-05-13T18:20:52Z Indexed on 2010/05/13 18:24 UTC
Read the original article Hit count: 162

Filed under:
|
|
|

I'm having trouble finding a clear explanation of connection pooling. I'm building an app using the .NET connector I downloaded from mysql.com. The app only needs one db connection but will be running simultaneously on about 6 machines on my network. Normally, I'd create the connection at startup and just leave it. But I'm seeing lots of posts from people who say that's bad practice. Also I'm concerned about timeouts. My app will run 24/7 and there may be extended periods without database activity.

I'm leaning toward the following:

using (MySqlConnection conn = new MySqlConnection(connStr)) { conn.Open(); // use connection }

But I'm not sure I understand what's going on in the background. Is this actually closing the connection and allowing gc to kill the object, or is there a built in pooling behavior that preserves the object and redelivers it the next time I try to create one?

I certainly don't want the app reauthenticating across the network every time I hit the database.

Can anyone offer me some advise?

© Stack Overflow or respective owner

Related posts about c#

Related posts about mysql