Grails 2.3.11 MySql断开连接

时间:2014-12-09 09:55:40

标签: mysql grails

我使用的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
    }
}

任何想法?

1 个答案:

答案 0 :(得分:1)

您需要在properties块中放置一些属性。

我在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
    }
}