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,回车;输入password,回车;

输入命令: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-10-13 00:53:46

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

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: &quot;Too many connections&quot;

最简单的办法是因为你的my.ini中设定的并发连接数太少或者系统繁忙导致连接数被占满解决方式:打开MySQL安装目录打开MY.INI找到max_connections默认是100 .--实例 WINDOWS解决mysql Errno.: 1040错误XXXX info: Can not connect to MySQL server User: rootTime: 2004-5-20 3:00pmScript: /XXXX/XXXX.PHP Error: Too many connections

Data source rejected establishment of connection, message from server: &quot;Too many connections&quot;

错误描述: 测试一段时间没有任何问题,今天突然用户无法登录,报错如Data source rejected establishment of connection,  message from server: "Too many connections" 错误原因: 太多的连接数,登录用户过多,配置的mysql连接数过小,或者某些连接没有关闭,导致连接数过大. 问题的解决: 修改mysql的my.ini配置文件,网上的说法:mysql安装目录下的my.ini中设定的并发连接数太少或者系

mysql: Data source rejected establishment of connection, message from server: &quot;Too many connections&quot;

http://www.oschina.net/question/558677_66703 com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Data source rejected establishment of connection,  message from server: "Too many connections" "Too many connections"错误 尝试加大 M

Data source rejected establishment of connection, message from server: &quot;Too many connections&quot;解决办法

异常名称 //数据源拒绝从服务器建立连接.消息:"连接太多" com.MySQL.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections" 原因一 MYSQL安装目录打开MY.INI. 找到max_connections

今天碰到报错 Data source rejected establishment of connection, message from server: &quot;Too many connections&quot;

字面上理解是太多连接,但是没有关闭.  百度了一下,说是因为连接打开太多,端口连接满了.去看mysql服务的占用端口 然后我把XML的默认端口改成就好了, 开始我直接写的是这个,估计要改一下端口才行.可以试试,具体有待探究.

前段时间,接手一个项目使用的是原始的jdbc作为数据库的访问,发布到服务器上在运行了一段时间之后总是会出现无法访问的情况,登录到服务器,查看tomcat日志发现总是报如下的错误。    Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected est

前段时间,接手一个项目使用的是原始的jdbc作为数据库的访问,发布到服务器上在运行了一段时间之后总是会出现无法访问的情况,登录到服务器,查看tomcat日志发现总是报如下的错误. Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too man

Configuring the WebSphere Application Server data source

Configuring the WebSphere Application Server data source Version WebSphere Application Server 7.0.0.x   WebSphere Application Server 8.0.0.x Installed applications use data sources as resources to obtain connection to relational databases. To create

[转] --- Error: “A field or property with the name was not found on the selected data source” get only on server

Error: “A field or property with the name was not found on the selected data source” get only on server up vote4down votefavorite2I publish my project without any warning on local iis and it works correctly (localhost/[myprojectName]). so, i upload t

data source 和initial catalog

initial catalog与database的区别是什么Initial Catalog: DataBase: 两者没有任何区别只是名称不一样,就好像是人类的真实姓名与曾用名一样..都可以叫你. ******************************************** Integrated Security=SSPI 这个表示以当前WINDOWS系统用户身去登录SQL SERVER服务器,如果SQL SERVER服务器不支持这种方式登录时,就会出错. 你可以使用SQL SERV