G
G
Green Chameleon2020-09-28 02:09:52
Scala
Green Chameleon, 2020-09-28 02:09:52

What is the problem of connecting the play.api.db package?

When creating a module for interacting with the database, an error of the following nature occurred:
object db is not a member of package play.api

package controllers
import javax.inject.Inject

import play.api.db.Database
import play.api.mvc._

class DBController @Inject()(db: Database, val controllerComponents: ControllerComponents)
  extends BaseController{

  def test() = Action{
    var outString = "Content\n"
    db.withConnection{conn =>
      val rs = conn.createStatement().executeQuery("any query")
      while (rs.next()){
        outString += rs.getString("any params")
      }
    }
    Ok(outString)
  }
}

Tell me, what could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-09-28
@Chame1eon

You need to add jdbc as a dependency.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question