MySql最大池大小已达到/到许多连接 [英] MySql max pool size reached / To many connections

查看:87
本文介绍了MySql最大池大小已达到/到许多连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在使用.net 3.5&用于开发和测试的mysql数据库5.0 mysql .net连接器5.2.5,用于访问数据库.与服务器的最大连接数设置为500.在编码中,我已经完成了&在执行查询后释放连接.但是工作了足够的时间(例如1或2个小时)后,出现连接过多"或达到最大池大小"的异常.当我打开mysql管理员时,我看到所有500个连接都处于睡眠状态.

我在网上搜索了&知道这是我正在使用的MySql版本中的错误,因此我安装了最新的数据库&驱动程序,但情况保持不变.

我可以知道解决此问题的方法吗?
任何帮助将不胜感激.谢谢.

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.

推荐答案

使用一段时间后关闭应用程序会发生什么,休眠数据库进程的数量会立即减少到合理的数量吗?如果发生这种情况,那么我认为您在代码中的某个位置不会关闭连接.

搜索此位置的另一个地方是连接池.对于初学者,您可以尝试禁用缓冲池,并查看服务器端的连接会发生什么情况.
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.


检查是否在try catch块的最后放置了连接?
check whether Are you disposing your connection in finally of try catch block?


是的,米卡,你是对的.有一个函数要求关闭&布置连接.我检查了&的定义找到对< pre lang ="c#"> conn = new MySqlConnection(constr)</pre>的调用再次创建新连接,而先前的连接未关闭.
我评论了上面的代码&现在它的工作非常好....:)

非常感谢你们俩的答复.
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.


这篇关于MySql最大池大小已达到/到许多连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆