質問

I just started working with play, and I modified the way I'm doing a SQL read and I'm now getting the following error:

[Exception: DB plugin is not registered.]

The code I have for this class is:

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) {}

}

I'm not sure this is even the best way to do this, but using the ~ chain seemed like I'd just end up duplicating a bunch of stuff.

役に立ちましたか?

解決

Turns out that somehow in the application.conf the line:

dbplugin=disabled

had arisen. Not sure, I know I didn't put it in there, but commenting it out and fixing the remaining config errors in the JDBC Url fixed the problem!

他のヒント

Just make sure you provide the database configuration. For example, if you are using Play Framework's tutorial, uncomment this section.

# 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=""**

For more information, see Play Framework Database Configuration

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top