我使用的 MySql 连接器在大约 5 小时后断开连接。我似乎不明白为什么。 这是我的配置:
production {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
driverClassName = "com.mysql.jdbc.Driver"
username = "user"
password = "pass"
url = "jdbc:mysql://localhost/app?autoReconnect=true&characterEncoding=utf8"
flush.mode = 'commit'
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
}
}
有什么想法吗?
最佳答案
您需要将一些属性放入properties
block 中。
我在 2.3.11 中使用它,它工作得很好:
dataSource {
logSql = false
dbCreate = "" //migrations!!
driverClassName = 'com.mysql.jdbc.Driver'
pooled = true
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
defaultTransactionIsolation = Connection.TRANSACTION_READ_COMMITTED
}
}
关于mysql - Grails 2.3.11 MySql 断开连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27375986/