© Prem Kumar Karunakaran 2020
P. K. KarunakaranIntroducing Play Frameworkhttps://doi.org/10.1007/978-1-4842-5645-9_7

7. Accessing Databases

Prem Kumar Karunakaran1 
(1)
Thiruvananthapuram, Kerala, India
 

Play 2 has excellent support for SQL databases. All the database-related configurations are maintained in the conf/application.conf file. By default, Play 2 provides support for JDBC connection pools (connection pools offer efficient and faster access to the database resources).

Configuring Database Support

Edit the build.sbt file and add
libraryDependencies += javaJdbc

This will enable the JDBC API for Play projects.

Now open the application.conf file and add the following content:
# Database configuration
# ~~~~~
# You can declare as many datasources as ...

Get Introducing Play Framework: Java Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.