Defining an alternate connection pool in Grails 2.3.6 -
i know that, @ point between grails 1.x , grails 2.x, default connection pooling library changed commons-dbcp
tomcat-dbcp
.
now, i'm trying configure either bonecp or hikaricp connection pooling library grails application.
however, see this answer offers solution might apply grails 1.x.
i found this gist, again, don't know grails version applies to.
so, possible define custom connection pool inside grails 2.3.6 application? thanks!
update: ok need tell grails not pool datasources, since hikaricp taking care of this.
i saw connection weirdness in apps if left switch on. instead say:
pooled = false
ok yeah, @joshua moore right.
i tried doing updated grails methods , relevant section of resources.groovy
file. far can understand, configuration values in datasource.groovy
pulled resources.groovy
@ runtime, after target runtime environment has been identified (development
, test
or production
).
def config = holders.config def datasources = config.findall { it.key.tostring().contains("datasource_") } datasources.each { key, value -> def ds = value "${key}"(hikaridatasource, { bean -> def hp = new properties() hp.username = ds.username hp.password = ds.password hp.connectiontimeout = 6000 hp.maximumpoolsize = 60 hp.jdbcurl = ds.url hp.driverclassname = ds.driverclassname hikariconfig hc = new hikariconfig(hp) bean.constructorargs = [hc] }) }
and relevant section of datasource.groovy
configuration:
// environment specific settings environments { development { datasource_myapp1 { pooled = false username = "configure_me_externally" password = "configure_me_externally" driverclassname = 'oracle.jdbc.oracledriver' dialect = 'org.hibernate.dialect.oracle10gdialect' url = 'jdbc:oracle:thin:@mydbhost1:1521/myserviceid1' } datasource_myapp2 { pooled = false username = "configure_me_externally" password = "configure_me_externally" driverclassname = 'oracle.jdbc.oracledriver' dialect = 'org.hibernate.dialect.oracle10gdialect' url = 'jdbc:oracle:thin:@mydbhost2:1521/myserviceid2' } } }
in case, it's pretty same test
, production
environments. thanks!
Comments
Post a Comment