Anorm knows nothing about what datasource you are using. Every method on anorm that talks to the database takes an implicit java.sql.Connection
parameter. It's up to you to decide where that connection comes from. Obviously the most common way is to use Play's DB
API, using DB.withConnection
or DB.withTransaction
, but you could write your own that uses your own datasource.
It's also possible to write a custom DB plugin and disable the default Play one which is based on bonecp, if you do this then you can use the Play DB API with your custom datasource. To do this, implement your own play.api.db.DBApi
and play.api.db.DBPlugin
implementations, create a play.plugins
file that has your db plugin registered (eg, with 100:com.foo.MyDbPlugin
in it), and then disable Play's built in one by adding dbplugin=disabled
in application.conf
.