异常信息:
- 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 **
处理方法:
C3P0增加以下配置信息:
- //获取connnection时测试是否有效
- testConnectionOnCheckin = true
- //自动测试的table名称
- automaticTestTable=C3P0TestTable
- //set to something much less than wait_timeout, prevents connections from going stale
- idleConnectionTestPeriod = 18000
- //set to something slightly less than wait_timeout, preventing 'stale' connections from being handed out
- maxIdleTime = 25000
- //if you can take the performance 'hit', set to "true"
- testConnectionOnCheckout = true