JDBC MySQL抱怨连接过多

问题描述:

发生这种情况时,我检查了我的数据库(请参阅下表),连接数未达到1000个的限制.这很奇怪……想知道是否有隐藏的硬限制被击中.

When this happens, i check in my db(refer to table below), the connections has not reach the limit of 1000. This is weird... wonder if there's a hidden hard limit being hit.

mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 1000  |
+-----------------+-------+

mysql> SHOW STATUS WHERE `variable_name` = 'Max_used_connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 510   |
+----------------------+-------+

仅供参考,我的应用程序与数据库的平均连接数为300.有什么想法吗?谢谢.

FYI, my application is having an average of 300 connections to the database. So any idea? Thanks.

我的设置:tomcat7,spring 3.1,tomcat7-dbcp,mysql5.5,java7

My setup: tomcat7, spring 3.1, tomcat7-dbcp, mysql5.5, java7

一种可能的解释是MySQL服务器达到了由主机操作系统施加的打开文件描述符数量的限制.

One possible explanation is that the MySQL server is hitting a limit on the number of open file descriptors imposed by the host OS.

例如,此博客文章描述了Debian上的一个问题:

For example, this blog posting describes a problem on Debian:

以下是关于同一问题的问答:

Here is a Q&A that talks about the same thing: