我刚刚开始使用play,我修改了我正在进行SQL读取的方式,现在我收到以下错误:
[Exception: DB plugin is not registered.]
我这节课的代码是:
package models
import play.api.db._
import play.api.Play.current
import anorm._
case class Housing(id: Long, rent: String, address: String, street0: String, street1: String, neighbourhood: String)
object Housing {
def all(): List[Housing] = DB.withConnection { implicit c =>
SQL("select * from housing")().map { row =>
Housing(row[Long]("id"), row[String]("rent"), row[String]("address"), row[String]("street0"),
row[String]("street1"), row[String]("neighbourhood"))
}.toList
}
def create(rent: String, address: String, street0: String, street1: String, neighbourhood: String) {}
def delete(id: Long) {}
}
我不确定这是否是最好的方法,但使用〜链似乎我最终会复制一堆东西。
答案 0 :(得分:13)
在application.conf中以某种方式证明了这一行:
dbplugin=disabled
出现了。不确定,我知道我没有把它放在那里,但是将它注释掉并修复JDBC Url中剩余的配置错误解决了这个问题!
答案 1 :(得分:13)
确保提供数据库配置。例如,如果您使用的是Play Framework教程,请取消注释此部分。
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
# db.default.driver=org.h2.Driver
# db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=""**
有关详细信息,请参阅Play Framework Database Configuration