Click here to Skip to main content
16,016,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,
I am using .net 3.5 & mysql database 5.0 for development & mysql .net connector 5.2.5 for accessing database.The maximum connections to server is set to 500.In coding I have taken care of closing & disposing the connection after executing the query.But after working for sufficient time (say 1 or 2 hr) I get the exception as "Too many connections" or "Maximum pool size reached". When I opened the mysql administrator I saw that all the 500 connections are in sleep state.

I searched on net & came to know that this was the bug in the version of MySql I am using so I installed the latest database & driver but scenario remains same.

May I know the fix for this problem?
Any help will be appreciated. Thanks.
Posted
Updated 6-Sep-11 20:52pm
v2

What happens when you close your app after using it for awhile, does the amount of sleeping database processes immediately decrease to reasonable amount. If that happens then I think somewhere in you're code you don't close the connection.

One other place to search for this is the connection pool. For starters you can try disabling pooling and see what happens with the connections at the server side.
 
Share this answer
 
check whether Are you disposing your connection in finally of try catch block?
 
Share this answer
 
Comments
bsaurabh 7-Sep-11 5:41am    
yes,connection is being disposed in finally block...
yes Mika, you were right.There was a function call for closing & disposing the connection. I checked the definition of it & found a call to <pre lang="c#">conn = new MySqlConnection(constr)</pre> which was creating the new connection again leaving the previous connection unclosed.
I commented the above line of code & now its working very fine.... :)

Thanks a lot to both of you for replying.
 
Share this answer
 
Comments
[no name] 17-Jan-13 7:48am    
Hey i am facing the same problem can you please help me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900