Grails MySQL MaxPoolSize

时间:2008-12-18 00:28:45

标签: mysql grails

使用mysql时如何在Grails中增加maxPoolSize?它似乎只使用默认连接池8个连接。

2 个答案:

答案 0 :(得分:6)

不幸的是,如果您希望获得对它的更多控制,您将需要自己配置dataSource spring bean。这可以通过在“grails-app / conf / spring / resources.groovy”

中定义bean来完成
beans = {

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

}

它将覆盖在“grails-app / conf / DataSource.groovy”中配置的默认Grails数据源。


可能还应该使用PropertyOverrideConfigurer(在Config.groovy中)覆盖默认grails DataSource.groovy配置的池大小属性:

beans = {
   dataSource.initialSize = 15
   dataSource.maxActive = 50
   dataSource.maxIdle = 15
}

答案 1 :(得分:3)

对于grails 1.2,您应该使用稍微不同的格式:

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