Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DB Plugin is not registered in Play 2.0

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.

like image 273
PlexQ Avatar asked Mar 25 '12 19:03

PlexQ


2 Answers

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!

like image 174
PlexQ Avatar answered Oct 16 '22 09:10

PlexQ


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

like image 35
Hanxue Avatar answered Oct 16 '22 10:10

Hanxue