hibernate批量插入数据,MySQL提示:1040-Too many connections

 2011-8-5 8:34:13 net.sf.ehcache.config.ConfigurationFactory parseConfiguration
警告: No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps/OgSchedule/WEB-INF/lib/ehcache-1.6.2.jar!/ehcache-failsafe.xml
2011-8-5 8:34:13 net.sf.ehcache.CacheManager detectAndFixDiskStorePathConflict
警告: Creating a new instance of CacheManager using the diskStorePath "C:\WINDOWS\TEMP\" which is already used by an existing CacheManager.
The source of the configuration was classpath.
The diskStore path for this CacheManager will be set to C:\WINDOWS\TEMP\\ehcache_auto_created_1312504453046.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
org.hibernate.exception.GenericJDBCException: Cannot open connection
。。。

=======================================================

原因:MySQL默认的连接数是100,太少!自己的SSH项目开的连接数比这个大。

解决:(windows环境)

1.到C:\Program Files\MySQL\MySQL Server 5.0下面找到my.ini文件,记事本打开,找到“max_connections=100”改成:max_connections=10000

2.设置SSH项目的c3p0.min_size(这里是c3p0连接池)小点,这里可以不去管它,不可能比10000大吧

3.管理工具--服务:重启MySQL服务


 

mysql manual有如下的说明:
mysqld actually allows
max_connections+1
clients to connect. The extra connection is reserved for use by accounts that have the
SUPER  privilege. By granting the  SUPER  privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected.
因此, 必须只赋予root用户的SUPER权限,同时所有数据库连接的帐户不能赋予SUPER权限。前面说到的报错后无法登录就是由于我们的应用程序直接配置的root用户

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值