mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-01-08 00:22:19 +01:00
Use HikariCP instead of c3p0
This commit is contained in:
@@ -36,7 +36,7 @@ libraryDependencies ++= Seq(
|
||||
"com.novell.ldap" % "jldap" % "2009-10-07",
|
||||
"com.h2database" % "h2" % "1.4.190",
|
||||
"ch.qos.logback" % "logback-classic" % "1.1.1",
|
||||
"com.mchange" % "c3p0" % "0.9.5.2",
|
||||
"com.zaxxer" % "HikariCP" % "2.4.5",
|
||||
"com.typesafe" % "config" % "1.3.0",
|
||||
"com.typesafe.akka" %% "akka-actor" % "2.3.14",
|
||||
"fr.brouillard.oss.security.xhub" % "xhub4j-core" % "1.0.0",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package gitbucket.core.model
|
||||
|
||||
import gitbucket.core.util.DatabaseConfig
|
||||
|
||||
|
||||
trait Profile {
|
||||
val profile: slick.driver.JdbcProfile
|
||||
@@ -29,11 +31,9 @@ trait Profile {
|
||||
|
||||
trait ProfileProvider { self: Profile =>
|
||||
|
||||
private val url = System.getProperty("db.url")
|
||||
// private val user = System.getProperty("db.user")
|
||||
// private val password = System.getProperty("db.password")
|
||||
private lazy val url = DatabaseConfig.url
|
||||
|
||||
val profile = if(url.indexOf("h2") >= 0){
|
||||
lazy val profile = if(url.indexOf("h2") >= 0){
|
||||
slick.driver.H2Driver
|
||||
} else if(url.indexOf("mysql") >= 0) {
|
||||
slick.driver.MySQLDriver
|
||||
|
||||
@@ -2,7 +2,7 @@ package gitbucket.core.servlet
|
||||
|
||||
import javax.servlet._
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource
|
||||
import com.zaxxer.hikari._
|
||||
import gitbucket.core.util.DatabaseConfig
|
||||
import org.scalatra.ScalatraBase
|
||||
import org.slf4j.LoggerFactory
|
||||
@@ -46,14 +46,14 @@ object Database {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(Database.getClass)
|
||||
|
||||
private val dataSource: ComboPooledDataSource = {
|
||||
val ds = new ComboPooledDataSource
|
||||
ds.setDriverClass(DatabaseConfig.driver)
|
||||
ds.setJdbcUrl(DatabaseConfig.url)
|
||||
ds.setUser(DatabaseConfig.user)
|
||||
ds.setPassword(DatabaseConfig.password)
|
||||
private val dataSource: HikariDataSource = {
|
||||
val config = new HikariConfig()
|
||||
config.setDriverClassName(DatabaseConfig.driver)
|
||||
config.setJdbcUrl(DatabaseConfig.url)
|
||||
config.setUsername(DatabaseConfig.user)
|
||||
config.setPassword(DatabaseConfig.password)
|
||||
logger.debug("load database connection pool")
|
||||
ds
|
||||
new HikariDataSource(config)
|
||||
}
|
||||
|
||||
private val db: SlickDatabase = {
|
||||
|
||||
Reference in New Issue
Block a user