java 浠g爜
- org.hibernate.exception.JDBCConnectionException: could not execute query
- at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
- at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
- .......
- Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:
-
-
- ** BEGIN NESTED EXCEPTION **
-
- com.mysql.jdbc.CommunicationsException
- MESSAGE: Communications link failure due to underlying exception:
-
- ** BEGIN NESTED EXCEPTION **
-
- java.net.SocketException
- MESSAGE: Broken pipe
-
- STACKTRACE:
-
- java.net.SocketException: Broken pipe
- at java.net.SocketOutputStream.socketWrite0(Native Method)
- ......
- ** END NESTED EXCEPTION **
鏌ョ湅浜哅ysql鐨勬枃妗o紝浠ュ強Connector/J鐨勬枃妗d互鍙婂湪綰胯鏄庡彂鐜幫紝鍑虹幇榪欑寮傚父鐨勫師鍥犳槸錛?/p>
Mysql鏈嶅姟鍣ㄩ粯璁ょ殑“wait_timeout”鏄?灝忔椂錛屼篃灝辨槸璇翠竴涓猚onnection絀洪棽瓚呰繃8涓皬鏃訛紝Mysql灝嗚嚜鍔ㄦ柇寮璇onnection銆傝繖灝辨槸闂鐨勬墍鍦紝鍦–3P0 pools涓殑connections濡傛灉絀洪棽瓚呰繃8灝忔椂錛孧ysql灝嗗叾鏂紑錛岃孋3P0騫朵笉鐭ラ亾璇onnection宸茬粡澶辨晥錛屽鏋滆繖鏃舵湁Client璇鋒眰connection錛孋3P0灝嗚澶辨晥鐨凜onnection鎻愪緵緇機lient錛屽皢浼氶犳垚涓婇潰鐨勫紓甯搞?/p>
瑙e喅鐨勬柟娉曟湁3縐嶏細
- 澧炲姞wait_timeout鐨勬椂闂淬?
- 鍑忓皯Connection pools涓璫onnection鐨刲ifetime銆?
- 嫻嬭瘯Connection pools涓璫onnection鐨勬湁鏁堟с?
褰撶劧鏈濂界殑鍔炴硶鏄悓鏃剁患鍚堜嬌鐢ㄤ笂榪?縐嶆柟娉曪紝涓嬮潰灝盌BCP鍜孋3P0鍒嗗埆鍋氫竴璇存槑錛屽亣璁緒ait_timeout涓洪粯璁ょ殑8灝忔椂
DBCP澧炲姞浠ヤ笅閰嶇疆淇℃伅:
-
- validationQuery = "SELECT 1"
-
- testWhileIdle = "true"
-
- timeBetweenEvictionRunsMillis = 3600000
-
- minEvictableIdleTimeMillis = 18000000
-
- testOnBorrow = "true"
C3P0澧炲姞浠ヤ笅閰嶇疆淇℃伅:
-
- preferredTestQuery = 'SELECT 1'
-
- idleConnectionTestPeriod = 18000
-
- maxIdleTime = 25000
-
- testConnectionOnCheckout = true
鏇村鐨勯厤緗俊鎭ぇ瀹跺彲浠ユ煡鐪婥3P0鏂囨。錛孋onnector/J鏂囨。錛屼互鍙奃BCP鐨勬枃妗c?/p>

]]>