Skip to content

Commit

Permalink
Some changes to the pool configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
karma4u101 committed Dec 8, 2011
1 parent f46de35 commit 069a65c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ libraryDependencies ++= {

// Customize any further dependencies as desired
libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-webapp" % "8.0.3.v20111011" % "container",
//"org.mortbay.jetty" % "jetty" % "6.1.22" % "container", // For Jetty 7
"org.eclipse.jetty" % "jetty-webapp" % "8.0.3.v20111011" % "test, container",
//"org.mortbay.jetty" % "jetty" % "6.1.22" % "test, container", // For Jetty 7
"javax.servlet" % "servlet-api" % "2.5" % "provided->default",
"org.mindrot" % "jbcrypt" % "0.3m" % "compile->default",
"com.h2database" % "h2" % "1.2.138", // In-process database, useful for development systems
Expand Down
24 changes: 11 additions & 13 deletions src/main/scala/code/model/MySchema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ object MySchemaHelper extends Loggable {
class MyH2DBSettings extends DBSettings with Loggable {
override val dbAdapter = new H2Adapter;
override val dbDriver = Props.get("h2.db.driver").openOr("org.h2.Driver")
//"jdbc:h2:mem:testSqRecDB;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=3000"
//"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=3000"
override val dbUrl = Props.get("h2.db.url").openOr("jdbc:h2:database/testXYZDB;FILE_LOCK=NO") //drop to h2 on harddrive
override val dbUser = Props.get("h2.db.user").openOr("test")
override val dbPass = Props.get("h2.db.pass").openOr("test")
Expand Down Expand Up @@ -117,36 +117,34 @@ object MySchemaHelper extends Loggable {
/* database connection pooling provider - we are using BoneCP */
object PoolProvider extends Loggable {

var pool: Box[BoneCP] = Empty
def getPoolConnection(db: DBSettings) : Connection = {
initPool(db).getConnection
}

private def doConfig(db: DBSettings) = {
private def initPool(db: DBSettings):BoneCP = {
// create a new configuration object
val config = new BoneCPConfig
try {
// load the DB driver class
Class.forName(db.dbDriver)
// create a new configuration object
val config = new BoneCPConfig
// set the JDBC url
config.setJdbcUrl(db.dbUrl)
// set the username
config.setUsername(db.dbUser)
// set the password
config.setPassword(db.dbPass)
// setup the connection pool
pool = Full(new BoneCP(config))
//pool = Full(new BoneCP(config))
logger.info("BoneCP connection pool is now initialized.")
new BoneCP(config)
} catch {
case e: Exception => {
logger.error("BoneCP - FAILED to initialize connection pool.")
e.printStackTrace
}
throw new java.lang.Exception("BoneCP - FAILED to initialize connection pool."+e.printStackTrace)
}
}
}

def getPoolConnection(db: DBSettings) : Connection = {
doConfig(db)
pool.openTheBox.getConnection
}

}

}
Expand Down

0 comments on commit 069a65c

Please sign in to comment.