Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

change database trait to require url options on connection creation

  • Loading branch information...
commit 7a0861c052c459d0da2cd16c09903f38c642f91b 1 parent 687575c
@freels freels authored
Showing with 10 additions and 6 deletions.
  1. +10 −6 src/main/scala/com/twitter/querulous/database/Database.scala
View
16 src/main/scala/com/twitter/querulous/database/Database.scala
@@ -34,8 +34,13 @@ object DatabaseFactory {
}
trait DatabaseFactory {
- def apply(dbhosts: List[String], dbname: String, username: String, password: String): Database
- def apply(dbhosts: List[String], username: String, password: String): Database
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: String): Database
+
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String): Database =
+ apply(dbhosts, dbname, username, password, null)
+
+ def apply(dbhosts: List[String], username: String, password: String): Database =
+ apply(dbhosts, null, username, password, null)
}
trait Database {
@@ -52,10 +57,9 @@ trait Database {
}
}
- protected def url(dbhosts: List[String], dbname: String) = {
+ protected def url(dbhosts: List[String], dbname: String, urlOptions: String) = {
val dbnameSegment = if (dbname == null) "" else ("/" + dbname)
- "jdbc:mysql://" + dbhosts.mkString(",") + dbnameSegment + "?" + urlOptions
+ val urlOptsSegment = if (urlOptions == null) "" else ("?" + urlOptions)
+ "jdbc:mysql://" + dbhosts.mkString(",") + dbnameSegment + urlOptsSegment
}
-
- def urlOptions = "useUnicode=true&characterEncoding=UTF-8&connectTimeout=500&socketTimeout=500"
}
Please sign in to comment.
Something went wrong with that request. Please try again.