tags:

views:

948

answers:

2

How do I increase the maxPoolSize in Grails when using mysql? It appears to be using a default connection pool only 8 connections.

+4  A: 

Unfortunately you will need to configure the dataSource spring bean for yourself if you want to gain more control over it. This can be done by defining the bean in "grails-app/conf/spring/resources.groovy"

beans = {

   dataSource(org.apache.commons.dbcp.BasicDataSource) {
      driverClassName = "com.mysql.jdbc.Driver"
      username = "someuser"
      password = "s3cret"
      initialSize = 15
      maxActive = 50
      maxIdle = 15
   }

}

It will override the default Grails DataSource which is configured in "grails-app/conf/DataSource.groovy".


Probably it should also work to override the pool-size properties of the default grails DataSource.groovy configuration like this leveraging the PropertyOverrideConfigurer (in Config.groovy):

beans = {
   dataSource.initialSize = 15
   dataSource.maxActive = 50
   dataSource.maxIdle = 15
}
Siegfried Puchbauer
A: 

For grails 1.2 you should use a little bit different format:

dataSource {
    pooled = true
    dbCreate = "update"
    url = "jdbc:mysql://localhost/yourDB"
    driverClassName = "com.mysql.jdbc.Driver"
    username = "yourUser"
    password = "yourPassword"
    properties {
        maxActive = 50
        maxIdle = 25
        minIdle = 5
        initialSize = 5
        minEvictableIdleTimeMillis = 60000
        timeBetweenEvictionRunsMillis = 60000
        maxWait = 10000     
    }   
}
uthark