Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix apache pooling database and single connection database for url op…

…tion specification
  • Loading branch information...
commit 11dee94d619dd954f257eb4d1277c7345c537001 1 parent 7a0861c
@freels freels authored
View
8 src/main/scala/com/twitter/querulous/database/ApachePoolingDatabase.scala
@@ -13,12 +13,13 @@ class ApachePoolingDatabaseFactory(
checkConnectionHealthOnReservation: Boolean,
evictConnectionIfIdleFor: Duration) extends DatabaseFactory {
- def apply(dbhosts: List[String], dbname: String, username: String, password: String) = {
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: String) = {
val pool = new ApachePoolingDatabase(
dbhosts,
dbname,
username,
password,
+ urlOptions,
minOpenConnections,
maxOpenConnections,
checkConnectionHealthWhenIdleFor,
@@ -27,8 +28,6 @@ class ApachePoolingDatabaseFactory(
evictConnectionIfIdleFor)
pool
}
-
- def apply(dbhosts: List[String], username: String, password: String) = apply(dbhosts, null, username, password)
}
class ApachePoolingDatabase(
@@ -36,6 +35,7 @@ class ApachePoolingDatabase(
dbname: String,
username: String,
password: String,
+ urlOptions: String,
minOpenConnections: Int,
maxOpenConnections: Int,
checkConnectionHealthWhenIdleFor: Duration,
@@ -57,7 +57,7 @@ class ApachePoolingDatabase(
config.minEvictableIdleTimeMillis = evictConnectionIfIdleFor.inMillis
private val connectionPool = new GenericObjectPool(null, config)
- private val connectionFactory = new DriverManagerConnectionFactory(url(dbhosts, dbname), username, password)
+ private val connectionFactory = new DriverManagerConnectionFactory(url(dbhosts, dbname, urlOptions), username, password)
private val poolableConnectionFactory = new PoolableConnectionFactory(
connectionFactory,
connectionPool,
View
9 src/main/scala/com/twitter/querulous/database/SingleConnectionDatabase.scala
@@ -5,16 +5,15 @@ import java.sql.{SQLException, Connection}
class SingleConnectionDatabaseFactory extends DatabaseFactory {
- def apply(dbhosts: List[String], dbname: String, username: String, password: String) = {
- new SingleConnectionDatabase(dbhosts, dbname, username, password)
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: String) = {
+ new SingleConnectionDatabase(dbhosts, dbname, username, password, urlOptions)
}
- def apply(dbhosts: List[String], username: String, password: String) = apply(dbhosts, null, username, password)
}
-class SingleConnectionDatabase(dbhosts: List[String], dbname: String, username: String, password: String)
+class SingleConnectionDatabase(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: String)
extends Database {
Class.forName("com.mysql.jdbc.Driver")
- private val connectionFactory = new DriverManagerConnectionFactory(url(dbhosts, dbname), username, password)
+ private val connectionFactory = new DriverManagerConnectionFactory(url(dbhosts, dbname, urlOptions), username, password)
def close(connection: Connection) {
try {
Please sign in to comment.
Something went wrong with that request. Please try again.