代码之家  ›  专栏  ›  技术社区  ›  Bob Herrmann

Grails MySQL MaxPoolSize

  •  5
  • Bob Herrmann  · 技术社区  · 17 年前

    2 回复  |  直到 17 年前
        1
  •  7
  •   Siegfried Puchbauer    17 年前

    不幸的是,如果您想获得对数据源Springbean的更多控制,您将需要为自己配置该数据源Springbean。这可以通过在“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 DataSource.groovy配置的池大小属性,比如利用PropertyOverrideConfiguler(在Config.groovy中):

    beans = {
       dataSource.initialSize = 15
       dataSource.maxActive = 50
       dataSource.maxIdle = 15
    }
    
        2
  •  4
  •   uthark    16 年前

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