0
votes

I am currently setting up a project that uses play slick with scala. From the docs I find that to get a session we should do

val db = Database.forDataSource(dataSource: javax.sql.DataSource)

So I followed the pattern and used this in every Repository layer.(A layer on top of model similar to a dao). I have couple of repositories and I have duplicated this line .

My question is , does this connect to database every time of have a common pool and we get the connection from this pool ?

1
What play version do you use?Mon Calamari
Play version 2 and slick verion 3 .Raghavan

1 Answers

1
votes

From slick documentation :

Using a DataSource You can provide a DataSource object to forDataSource. If you got it from the connection pool of your application framework, this plugs the pool into Slick.

val db = Database.forDataSource(dataSource: javax.sql.DataSource)

When you later create a Session, a connection is acquired from the pool and when the Session is closed it is returned to the pool.