Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
Created May 12, 2011 19:05
Show Gist options
  • Save fmpwizard/969218 to your computer and use it in GitHub Desktop.
Save fmpwizard/969218 to your computer and use it in GitHub Desktop.
Class Boot {
...
def boot {
if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor)
...
}
}
object DBVendor extends ConnectionManager with Logger {
def newConnection(name: ConnectionIdentifier): Box[Connection] = {
try {
Class.forName("com.mysql.jdbc.Driver")
val jdbcurl= (Props.get("db.url") openOr "") +
"?user=" + (Props.get("db.user") openOr "") +
"&password=" + (Props.get("db.password") openOr "") +
"&" + Props.get("additionalurlparam").openOr("")
debug( jdbcurl)
val dm = DriverManager.getConnection(jdbcurl)
Full(dm)
} catch {
case e : Exception => e.printStackTrace; Empty
}
}
def releaseConnection(conn: Connection) {conn.close}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment