Data source rejected establishment of connection, message from server: "Too many connections"

详细错误信息:

严重: StandardWrapper.Throwable
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.SQLNestedException: Error preloading the connection pool
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:241)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633)
at com.qujiu.base.service.XgPlatformManager$$EnhancerBySpringCGLIB$$112e244c.getPlarMark(<generated>)
at com.qujiu.base.web.init.BaseDataDictionary.init(BaseDataDictionary.java:40)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.commons.dbcp.SQLNestedException: Error preloading the connection pool
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:868)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:203)
... 20 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1104)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:996)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:865)
... 22 more

七月 30, 2014 12:04:20 下午 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /wowo-web threw load() exception
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1104)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:996)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:865)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:203)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633)
at com.qujiu.base.service.XgPlatformManager$$EnhancerBySpringCGLIB$$112e244c.getPlarMark(<generated>)
at com.qujiu.base.web.init.BaseDataDictionary.init(BaseDataDictionary.java:40)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

七月 30, 2014 12:04:20 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring FrameworkServlet 'springmvc'
七月 30, 2014 12:04:21 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
七月 30, 2014 12:04:21 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
七月 30, 2014 12:04:21 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 18779 ms

问题分析:

查看MySQL的当前最大连接数,登录MySQL:mysql -uroot -p,回车;输入密码,回车;

输入命令:select VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='MAX_CONNECTIONS'; 回车

显示当前最大连接数为:151,之前通过文章“CentOS下mysql最大连接数设置 1040 too many connection”中的方法设置为3600了,现在怎么又变成151了?原来这个方法只是临时的修改了最大连接数,重新启动MySQL服务后就还原了。

解决问题:

要彻底解决问题还是要修改my.cnf配置文件,这里使用VI来修改,输入命令:vi /usr/my.cnf 回车;打开文件后按“i”键进入编辑状态;

在“[mysqld]”下面添加“max_connections=3600”,按Esc键进入命令模式,输入“:wq”回车(保存并退出)。

执行:service mysql restart 重新启动MySQL服务;启动服务的时间可能有点长,耐心等待……

注意:很多文章中提到在“[mysqld]”下面添加“set-variable=max_connections=1000”,根本不行,加了之后服务就启动不了了。

我这的环境是:CentOS 6.5 MySQL 5.6

时间: 2024-09-20 05:32:49

Data source rejected establishment of connection, message from server: "Too many connections"的相关文章

异常-message from server: &amp;amp;quot;Too many connections&amp;amp;quot;

问题描述 message from server: "Too many connections" 异常如下: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections" 问题描述: 将项目部署好后,没过

配置weblogic的connection pool和Data Source

connection|web os version:windwos2000 serverhostname:mytestdatabase:oracle 9.2.0.1port:1521table: test(a number(2))user:systempassword:oracleweblogic version: 7.0.4domain:mydomainserver:myserverport:7001WL_HOME:d:\bea\weblogic1.配置connection pool打開web

cacti 如何批量建立数据源data source

问题描述 cacti 如何批量建立数据源data source cacti 如何批量建立数据源data source,cacti自带的方法里只有批量新增主机 tree 和图 没看到有批量新增数据源的脚本呢 解决方案 http://os.51cto.com/art/201103/250983.htmhttp://www.linuxidc.com/Linux/2012-11/74634.htm

解决Lost connection to MySQL server during query错误方法

昨天使用Navicat for MySQL导入MySQL数据库的时候,出现了一个严重的错误,Lost connection to MySQL server during query,字面意思就是在查询过程中丢失连接到MySQL服务器. [Msg] Decompressing... [Msg] Table Created: wp_wiki_copy [Msg] Importing Data... [Msg] 2013 - Lost connection to MySQL server during

MYSQL:Lost connection to MySQL server at reading initial communication packet

Error: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 Errno.: 2013 如果是一直这样大家可尝试 在服务那里开启mysql的服务,我的电脑--右键管理--服务和应用程序--找mysql---右键属性--启动 你在命令行能不能进去?不能进去就是你密码错了 无论通过什么途径远程访问都出现错误可以认为是系统有防火墙之类的限制,解决方法是在 my.cnf

mysqldump 导出发生Lost connection to MySQL server during query

在mysqldump备份导出的时候类似用如下语句导出数据 mysqldump -uroot -p'passwd' –opt –default-character-set=utf8 –triggers -R –hex-blob –single-transaction –no-autocommit –master-data=2 test_game mail >mail.sql 出现类似如下报错: mysqldump: Error 2013: Lost connection to MySQL serv

Lost connection to MySQL server during query的解决_Mysql

Error: Lost connection to MySQL server during query  错误信息很明显了,在查询的时候丢失了和MYSQL数据库服务器的连接.  MYSQL不稳定. 

mysql报错:Lost connection to MySQL server at &#039;reading initial communication packet&#039;问题

问题分析 innodb_buffer_pool_size = 2048M 设置过大,调整为innodb_buffer_pool_size = 1024M即可 解决办法 找到my.cnf 然后把innodb_buffer_pool_size 设置合合适的 # might be limited to 2-3.5G of user level memory per process, so do not # set it too high. innodb_buffer_pool_size=187M 意思

MySQL远程连接丢失问题解决方法(Lost connection to MySQL server)_Mysql

最近服务器很不稳定,于是重装了mysql 和php 服务,但是接着却遇到了很头疼的麻烦. 远程连接mysql是总是提示: 复制代码 代码如下: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 很明显这是连接初始化阶段就丢失了连接的错误. google半天大多是说的注释掉配置文件中 bind-address = 127.0.0.1 这一句. 但是我的配置文件并没有配