我有一个具有高活性的飘雪,但后来经常不活动,可以持续几个小时,过夜的时期一个Grails应用程序。 我注意到,在上午第一个用户可以得到以下类型的异常的,我相信这是由于在游泳池去陈旧和MySQL数据库关闭它们的连接。
我在谷歌上搜索关于是否使用Connector / J连接属性“autoReconnect的=真”是一个好主意(和客户端是否会仍然得到即使连接,然后恢复除外),或是否设置发现冲突信息其他性质,将周期性地逐出或刷新的空闲连接,上借试验等Grails使用DBCP下方。 我现在有一个简单的配置如下,并在寻找如何最好地确保任何连接抓起出池后长期不活动时段是有效的,而不是封闭的答案。
dataSource {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://my.ip.address:3306/databasename"
driverClassName = "com.mysql.jdbc.Driver"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
username = "****"
password = "****"
properties {
//what should I add here?
}
}
例外
2012-06-20 08:40:55,150 [http-bio-8443-exec-1] ERROR transaction.JDBCTransaction - JDBC begin failed
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 64,129,968 milliseconds ago. The last packet sent successfully to the server was 64,129,968 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3851)
...... Lots more .......
Caused by: java.sql.SQLException: Already closed.
at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114)