Last active
April 1, 2016 05:20
-
-
Save cofemei/4bdbd5528c6fc2545e58e1e0a60512aa to your computer and use it in GitHub Desktop.
hikariCP connection pool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.zaxxer.hikari.HikariConfig | |
import com.zaxxer.hikari.HikariDataSource | |
// Place your Spring DSL code here | |
beans = { | |
def config = application.config | |
println config | |
def dataSources = config.findAll { | |
pritnln it.key.toString() | |
it.key.toString().contains("dataSource") | |
} | |
dataSources.each { key, value -> | |
println 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] | |
}) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment