From c99a22749938e730106d02f081365019d538e355 Mon Sep 17 00:00:00 2001 From: Andrew Olson Date: Mon, 6 Jul 2015 10:13:30 -0500 Subject: [PATCH] Switch database connection pool from DBCP2 to HikariCP --- project/Project.scala | 2 +- .../scala/com/twitter/zipkin/storage/anormdb/DB.scala | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/project/Project.scala b/project/Project.scala index 0790410a3e3..80e5fbfc08b 100644 --- a/project/Project.scala +++ b/project/Project.scala @@ -271,7 +271,7 @@ object Zipkin extends Build { ).settings( libraryDependencies ++= Seq( "com.typesafe.play" %% "anorm" % "2.3.7", - "org.apache.commons" % "commons-dbcp2" % "2.1", + "com.zaxxer" % "HikariCP-java6" % "2.3.8", anormDriverDependencies("sqlite-persistent") ) ++ testDependencies ++ scalaTestDeps, diff --git a/zipkin-anormdb/src/main/scala/com/twitter/zipkin/storage/anormdb/DB.scala b/zipkin-anormdb/src/main/scala/com/twitter/zipkin/storage/anormdb/DB.scala index 94915c2ad34..2f4947c4a6a 100644 --- a/zipkin-anormdb/src/main/scala/com/twitter/zipkin/storage/anormdb/DB.scala +++ b/zipkin-anormdb/src/main/scala/com/twitter/zipkin/storage/anormdb/DB.scala @@ -21,7 +21,7 @@ import anorm.SqlParser._ import java.sql.{Blob, Connection, DriverManager, SQLException, SQLRecoverableException, PreparedStatement} import com.twitter.util.{Try, Return, Throw, Future} import AnormThreads.inNewThread -import org.apache.commons.dbcp2.BasicDataSource +import com.zaxxer.hikari.HikariDataSource /** * Provides SQL database access via Anorm from the Play framework. @@ -38,10 +38,10 @@ case class DB(dbconfig: DBConfig = new DBConfig()) { if (dbconfig.install) this.install().close() // Initialize connection pool - private val connpool = new BasicDataSource() + private val connpool = new HikariDataSource() connpool.setDriverClassName(dbconfig.driver) - connpool.setUrl(dbconfig.location) - connpool.setMaxTotal(32) + connpool.setJdbcUrl(dbconfig.location) + connpool.setMaximumPoolSize(32) /** * Gets a dedicated java.sql.Connection to the SQL database. Note that auto-commit is