Skip to content

Commit

Permalink
Merge pull request playframework#5567 from wsargent/add-bonecp-specif…
Browse files Browse the repository at this point in the history
…ic-config

Add a test and a note for bonecp settings
  • Loading branch information
marcospereira committed Feb 5, 2016
2 parents 721d429 + 5286a01 commit 220fe82
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--- Copyright (C) 2009-2016 Typesafe Inc. <http://www.typesafe.com> -->
# Configuring the JDBC pool.

The Play JDBC datasource is managed by [HikariCP](https://brettwooldridge.github.io/HikariCP/).
The Play JDBC datasource is managed by [HikariCP](https://brettwooldridge.github.io/HikariCP/).

## Special URLs

Expand All @@ -25,9 +25,15 @@ db.default.url="mysql://user:password@localhost:port/database"
db.default.url="postgres://user:password@localhost:port/database"
```


## Reference

In addition to the classical `driver`, `url`, `username`, `password` configuration properties, it also supports additional tuning parameters if you need them. The `play.db.prototype` configuration from the Play JDBC `reference.conf` is used as the prototype for the configuration for all database connections. The defaults for all the available configuration options can be seen here:

@[](/confs/play-jdbc/reference.conf)
@[](/confs/play-jdbc/reference.conf)

When you need to specify some settings for a connection pool, you can override the prototype settings. For example, to set the default connection pool for BoneCP and set maxConnectionsPerPartition for the default pool, you would set the following in your `application.conf` file:

```
play.db.pool=bonecp
play.db.prototype.bonecp.maxConnectionsPerPartition = 50
```
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ class ConnectionPoolConfigSpec extends PlaySpecification {
}
}

"use BoneCP with 'bonecp' specific settings" in new WithApplication(FakeApplication(
additionalConfiguration = Map(
"play.db.pool" -> "bonecp",
"db.default.url" -> "jdbc:h2:mem:default",
"db.other.driver" -> "org.h2.Driver",
"db.other.url" -> "jdbc:h2:mem:other",
"play.db.prototype.bonecp.maxConnectionsPerPartition" -> "50"
)
)) {
import com.jolbox.bonecp.BoneCPDataSource
val db = app.injector.instanceOf[DBApi]
val bonecpDataSource: BoneCPDataSource = db.database("default").dataSource.asInstanceOf[BoneCPDataSource]
val bonecpConfig = bonecpDataSource.getConfig
bonecpConfig.getMaxConnectionsPerPartition must be_==(50)
}

"use BoneCP when database-specific pool is 'bonecp'" in new WithApplication(FakeApplication(
additionalConfiguration = Map(
"db.default.pool" -> "bonecp",
Expand All @@ -67,4 +83,4 @@ class ConnectionPoolConfigSpec extends PlaySpecification {

}

}
}

0 comments on commit 220fe82

Please sign in to comment.