Back to Playframework

Configuring the JDBC pool

documentation/manual/working/commonGuide/configuration/SettingsJDBC.md

3.1.0-M91.9 KB
Original Source
<!--- Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com> -->

Configuring the JDBC pool

The Play JDBC datasource is managed by HikariCP.

Special URLs

Play supports special url format for both MySQL and PostgreSQL:

properties
# To configure MySQL
db.default.url="mysql://user:password@localhost/database"

# To configure PostgreSQL
db.default.url="postgres://user:password@localhost/database"

A non-standard port of the database service can be specified:

properties
# To configure MySQL running in Docker
db.default.url="mysql://user:password@localhost:port/database"

# To configure PostgreSQL running in Docker
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:

@

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

properties
db.default.hikaricp.maximumPoolSize = 15

In case you need to specify some driver-specific properties for connections in the pool, you can set them in the dataSource configuration. For example, to set queryTimeout of the jdbc SQLServerDriver using HikariCP, you would set the following in your application.conf file:

properties
db.default.hikaricp.dataSource.queryTimeout = 15