MySQL Connection Timeout Issue - Grails Application on Tomcat using Hibernate and ORM

后端 未结 7 2128
青春惊慌失措
青春惊慌失措 2020-12-08 07:42

I have a small grails application running on Tomcat in Ubuntu on a VPS. I use MySql as my datastore and everything works fine unless I leave the application for more than ha

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 08:16

    Starting from grails 2.3.6 default configuration already has options for preventing closing connection by timeout

    These are the new defaults.

        properties {
           // See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
           ....
           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 = java.sql.Connection.TRANSACTION_READ_COMMITTED
        }
    

提交回复
热议问题