2012-03-25 45 views
10

我剛開始玩的工作,而且我修改我在做一個SQL讀,現在我得到下面的錯誤方式:DB插件不在場上註冊2.0

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

} 

我不知道這甚至要做到這一點的最好辦法,但使用〜連鎖好像我剛剛結束了複製了一堆東西。

回答

13

原來,不知何故在application.conf行:

dbplugin=disabled 

已經出現。不知道,我知道我沒有把它放在那裏,但註釋掉它並修復JDBC Url中剩餘的配置錯誤修復了問題!

+0

+1這只是發生在我身上 – 2012-03-28 10:20:59

+1

我有同樣的問題。我忘了取消註釋這一個db.default.driver。 – 2013-02-13 20:05:29

+1

我根本沒有這條線 – ses 2013-06-28 02:44:47

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

+0

非常有用。正在逐步完成教程並忘記了這一點! – Filip 2013-10-20 18:52:57

+0

根據2.2版的相關答案 – 2014-04-02 07:57:08