Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0dc85500d6
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (22 sloc) 0.986 kb
package com.twitter.querulous.database
import org.apache.commons.dbcp.DriverManagerConnectionFactory
import java.sql.{SQLException, Connection}
class SingleConnectionDatabaseFactory extends DatabaseFactory {
def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: Map[String, String]) = {
new SingleConnectionDatabase(dbhosts, dbname, username, password, urlOptions)
}
}
class SingleConnectionDatabase(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: Map[String, String])
extends Database {
Class.forName("com.mysql.jdbc.Driver")
private val connectionFactory = new DriverManagerConnectionFactory(url(dbhosts, dbname, urlOptions), username, password)
def close(connection: Connection) {
try {
connection.close()
} catch {
case _: SQLException =>
}
}
def open() = connectionFactory.createConnection()
override def toString = dbhosts.first + "_" + dbname
}
Jump to Line
Something went wrong with that request. Please try again.