Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Play Scala JDBC Config
package models
import javax.inject._
import play.api.libs.concurrent.CustomExecutionContext
* This class is a pointer to an execution context configured to point to "database.dispatcher"
* in the "application.conf" file.
class DatabaseExecutionContext @Inject()(system: ActorSystem) extends CustomExecutionContext(system, "database.dispatcher")
# Default database configuration using H2 database engine in a persistent mode
# db connections = ((physical_core_count * 2) + effective_spindle_count)
fixedConnectionPool = 9
database.dispatcher {
executor = "thread-pool-executor"
throughput = 1
thread-pool-executor {
fixed-pool-size = ${fixedConnectionPool}
import javax.inject.Inject
import play.api.db.Database
import scala.concurrent.Future
class ScalaApplicationDatabase @Inject() (db: Database, databaseExecutionContext: DatabaseExecutionContext) {
def updateSomething(): Unit = {
Future {
db.withConnection { conn =>
// do whatever you need with the db connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.