Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.09 KB | None | 0 0
  1. import com.mchange.v2.c3p0.ComboPooledDataSource
  2. import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH
  3. import org.codehaus.groovy.grails.commons.GrailsApplication
  4. import grails.util.GrailsUtil
  5.  
  6.  
  7. // Place your Spring DSL code here
  8. beans = {
  9.    
  10.     /**
  11.     * c3P0 pooled data source that allows 'DB keepalive' queries
  12.     * to prevent stale/closed DB connections
  13.     * Still using the JDBC configuration settings from DataSource.groovy
  14.     * to have easy environment specific setup available
  15.     */
  16.    
  17.        
  18.         dataSource(ComboPooledDataSource) { bean ->
  19.             bean.destroyMethod = 'close'
  20.            
  21.             def ds = CH.config.dataSource
  22.            
  23.             user = ds.username
  24.             password = ds.password
  25.             driverClass = ds.driverClassName
  26.             jdbcUrl = ds.url
  27.            
  28.             initialPoolSize = 5
  29.             minPoolSize = 5
  30.             maxPoolSize = 30
  31.             acquireIncrement = 3
  32.            
  33.             maxConnectionAge = 2 * 60 * 60
  34.             maxIdleTime = 60 * 60
  35.            
  36.             maxStatements = 0
  37.             maxStatementsPerConnection = 0
  38.            
  39.             numHelperThreads = 10
  40.            
  41.             idleConnectionTestPeriod = 240
  42.             preferredTestQuery = "select 1"
  43.             testConnectionOnCheckin = true
  44.         }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement