加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Scala – DB插件尚未在Play 2.0中注册

发布时间:2020-12-16 21:31:15 所属栏目:安全 来源:网络整理
导读:我刚刚开始玩游戏,我修改了我在做一个SQL读取的方式,我现在得到以下错误: [Exception: DB plugin is not registered.] 这个类的代码是: package modelsimport play.api.db._import play.api.Play.currentimport anorm._case class Housing(id: Long,rent:
我刚刚开始玩游戏,我修改了我在做一个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,neighbourhood: String) {}

  def delete(id: Long) {}

}

我不知道这是甚么最好的方法,但是使用?链似乎是最终重复了一堆东西.

解决方法

只需确保提供数据库配置.例如,如果您正在使用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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读