I am using Slick 3.x with Play 2.3.9 without play-slick because play-slick does not support this combination. I read
And it mentioned that database connection must be closed explicitly ie
def delete(id: Long): Future[Int] =
try db.run(filterQuery(id).delete)
finally db.close
Do I have to close the connection explicitly as mentioned in the article? Will db.close
closes the connection and pool? Because, OTH, the examples in Slick 3.0 document didn't close the connection explicitly. I could have misunderstood the document. Thanks
I checked MySQL processes list, show processlist
, and found that the application did not connect more than what was specified in the application settings and continued to accept requests more than the allowable database connections. This shows that after every request the db connection is returned to the pool within db.run(...)
and db.close is not required.
db.close closes the connection pool. You probably don't want to do that. The way its written the db will likely close before the database query is processed.
db.close doesn't close connections or statements. That was automajically done for you within the db.run() clause
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.