mysql - Grails 2.3.11 MySql 断开连接

标签 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
    }
}

有什么想法吗?

最佳答案

您需要将一些属性放入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/

相关文章:

mysql - 根据连接表的结果更新 MySQL 表

Mysql 唯一约束允许单行组合

mysql - eclipselink MySQL左连接错误: unknown column

mysql - 根据订单列交换 Oracle 中的两条记录

grails - 我如何在 Spring Security Grails 上自定义/登录/验证?

grails - Grails集成测试:失败...无法在空对象上调用方法addToPosts()

Grails 和 Spring 安全 : Salt Value Must Be Null When Use with Crypto Module PasswordEncoder

java.sql.SQLException : Parameter index out of range (3 > number of parameters, 这是 2)

Grails:Groovy:SSLPeerUnverifiedException: 对等方未通过身份验证

hibernate - HQL:如果有时为空,如何筛选属性