代码工作正常,但我注意到有时它会给出错误
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
No operations allowed after connection closed.
我正在使用一个简单的查询,它总是来到这里(直到现在)。
def result(id: String,mark:String) = {
DB.withConnection { implicit c =>
val result = SQL("SELECT mark FROM `subject` WHERE id={id}").on("id" -> id).apply().head
if (result[String]("mark").equals(mark)) {
Map("result" -> true)
} else {
Map("result" -> false)
}
}
}
如果需要,我会提供更多信息,因为我在这段代码中似乎没有任何错误。
我必须对此做些什么吗?
application.conf
contexts {
simple-db-lookups {
fork-join-executor {
parallelism-factor = 10.0
}
}
expensive-db-lookups {
fork-join-executor {
parallelism-max = 4
}
}
db-write-operations {
fork-join-executor {
parallelism-factor = 2.0
}
}
expensive-cpu-operations {
fork-join-executor {
parallelism-max = 2
}
}
}
我正在使用scala 2.10和play framework 2.2