Data source rejected establishment of connection, message from server: "Too many connections&qu
Posted 艺意
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Data source rejected establishment of connection, message from server: "Too many connections&qu相关的知识,希望对你有一定的参考价值。
异常名称
//数据源拒绝从服务器建立连接、消息:“连接太多” com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"
原因一
- MYSQL安装目录打开MY.INI。
- 找到max_connections(在大约第93行)默认是100 一般设置到500~1000比较合适。
-
max_connections=1000
- 重启mysql,这样1040错误就解决啦。
原因二
还有一个可能就是代码里打开了太多的连接,但是忘记了在finally块里面关闭,从而导致在处理大数据的时候,抛出异常。下面这样的代码就不会有异常了。
try{ conn=Good.getConnection(); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); String sql1="insert into cat_garbage values(‘"+rs.getInt("id")+"‘,‘"+rs.getInt("cid")+"‘,‘"+rs.getString("name")+"‘,‘"+rs.getString("keyword")+"‘)"; stmt.executeUpdate(sql1); } catch(SQLException|ClassNotFoundException|IOException e) { e.printStackTrace(); } finally { if(stmt!= null) stmt.close(); if(conn!= null) conn.close(); } }
本文章参考:吴孟达
以上是关于Data source rejected establishment of connection, message from server: "Too many connections&qu的主要内容,如果未能解决你的问题,请参考以下文章
Data source rejected establishment of connection, message from server: "Too many connections&q
Data source rejected establishment of connection, message from server: "Too many connections&qu
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establish
Data source rejected establishment of connection, message from server: "Too many connections&qu
Data source rejected establishment of connection, message from server: "Too many connections&qu
今天碰到报错 Data source rejected establishment of connection, message from server: "Too many conne