我在 play 2.1.3 应用程序中使用 play-slick。
这是插入记录的代码
def insert = DBAction { implicit rs =>
recordForm.bindFromRequest.fold (
formWithErrors => {
Redirect(HomePage).flashing("alert-error" -> "Enter proper values")
},
record => {
Records.insert(record)
Redirect(HomePage).flashing("alert-success" -> "Record inserted successfully")
}
)
}
上面的代码正在泄漏连接,应用程序在 30 多个请求后抛出以下错误
java.sql.SQLException: Timed out waiting for a free available connection.
at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:503) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:114) ~[bonecp.jar:0.7.1.RELEASE]
at scala.slick.session.PlayDatabase.createConnection(PlayDatabase.scala:9) ~[na:na]
at scala.slick.session.BaseSession.conn$lzycompute(Session.scala:207) ~[slick_2.10-1.0.1.jar:1.0.1]
at scala.slick.session.BaseSession.conn(Session.scala:207) ~[slick_2.10-1.0.1.jar:1.0.1]
at scala.slick.session.Session$class.prepareStatement(Session.scala:29) ~[slick_2.10-1.0.1.jar:1.0.1]
报告了类似的问题,但此代码略有不同。
任何想法?