grails链接mysql_Grails 2.3.0和mysql连接超时

我有一个Grails 2.2.3应用程序使用此配置连接到mysql数据库:

production {

dataSource {

dbCreate = "update" // one of 'create', 'create-drop','update'

url = "jdbc:mysql://localhost/database?autoReconnect=true"

pooled = true

properties {

maxActive = 50

maxIdle = 25

minIdle = 5

initialSize = 5

minEvictableIdleTimeMillis = 1800000

timeBetweenEvictionRunsMillis = 1800000

maxWait = 10000

}

}

}

升级到Grails 2.3.0后,这已停止工作,在应用程序上周末不活动后,我收到此异常:

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 50,139,380 milliseconds ago. The last packet sent successfully to the server was 50,139,380 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:3352)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1971)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619)

at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4997)

... 5 more

Caused by: java.net.SocketException: Write failed: Broken pipe

at jrockit.net.SocketNativeIO.socketWrite(SocketNativeIO.java:46)

有任何想法吗 ?

解决方法:

尝试将以下“testOn”属性添加到连接池配置中:

properties {

...

testOnBorrow = true

testWhileIdle = true

testOnReturn = false

validationQuery = "SELECT 1"

}

值得以各种组合尝试这些标志.可能需要进行更改才能在您的环境中获得最佳性能

标签:mysql,grails

来源: https://codeday.me/bug/20190517/1121229.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值