Skip to content

Instantly share code, notes, and snippets.

@cofemei
Last active April 1, 2016 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cofemei/4bdbd5528c6fc2545e58e1e0a60512aa to your computer and use it in GitHub Desktop.
Save cofemei/4bdbd5528c6fc2545e58e1e0a60512aa to your computer and use it in GitHub Desktop.
hikariCP connection pool
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