Mysql的错误,待解决[已解决]Data source rejected establishment of connection message from server: "Too many connections";

[15:22:53,461] [CustomExceptionHandler,44] - Handle Exception:Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [08004]; error code [1040]; Data source rejected establishment of connection message from server: "Too many connections"; nested exception is java.sql.SQLException: Data source rejected establishment of connection message from server: "Too many connections"
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [08004]; error code [1040]; Data source rejected establishment of connection message from server: "Too many connections"; nested exception is java.sql.SQLException: Data source rejected establishment of connection message from server: "Too many connections"
java.sql.SQLException: Data source rejected establishment of connection message from server: "Too many connections"
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1906)
 at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:2535)
 at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:817)
 at com.mysql.jdbc.Connection.createNewIO(Connection.java:1782)
 at com.mysql.jdbc.Connection.(Connection.java:450)
 at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411)
 at java.sql.DriverManager.getConnection(DriverManager.java:525)
 at java.sql.DriverManager.getConnection(DriverManager.java:140)
 at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:291)
 at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:277)
 at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:259)
 at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:241)
 at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:80)
 at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:315)
 at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:109)
 at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
 at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
 at org.hibernate.loader.Loader.doQuery(Loader.java:661)
 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
 at org.hibernate.loader.Loader.doList(Loader.java:2150)
 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
 at org.hibernate.loader.Loader.list(Loader.java:2024)
 at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
 at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:300)
 at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:146)
 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1093)
 at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
 at com.easou.framework.dao.hibernate.BaseDAOHibernate.pageListQuery(BaseDAOHibernate.java:164)
 at com.vitamin.cn.manager.news.dao.hibernate.NewsDAOHibernate.searchNews(NewsDAOHibernate.java:38)
 at com.vitamin.cn.manager.news.bl.impl.NewsManagerImpl.searchNews(NewsManagerImpl.java:24)
 at com.vitamin.cn.manager.news.action.NewsAction.listNews(NewsAction.java:88)
 at com.vitamin.cn.manager.news.action.NewsAction.execute(NewsAction.java:35)
 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 at com.easou.framework.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:88)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
 at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
 at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
 at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
 at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 at java.lang.Thread.run(Thread.java:595)

1.可能是mysql的max connections设置的问题
2.可能是多次insert,update操作没有关闭session,需要在spring里配置transaction支持。

解决:
 1.修改tomcat里的session 的time-out时间减少为20,(不是必改项)
 2.对处理量大的对数据库insert或update的操作提供transaction支持.

你可能感兴趣的:(Mysql[工具])