hibernate批量插入資料,MySQL提示:1040-Too many connections

來源:互聯網
上載者:User

 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使用者

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.