0

I have following code. I'm using Play 2.3.7, Scala 2.11.4, PostgreSQL 9.4.1.

I get error execute following code:-

   val dburl: Option[String] = current.configuration.getString("db.default.url")
   val driver: Option[String] = current.configuration.getString("db.default.driver")
   val db = Database.forURL(dburl.get, driver.get)
   val session = db.createSession()

 def newPlayer(email: String, nickname: String): Int = {
    val now : java.sql.Timestamp = new java.sql.Timestamp(compat.Platform.currentTime)

    // following line throws exception  
  db.withSession {implicit session: Session => persons.map(p => (p.nickname, p.email, p.status, p.gender, p.created, p.updated)) += (nickname, email, "active", "n", now, now)}
  }

Execution exception

[PSQLException: FATAL: role "org.postgresql.Driver" does not exist]

I think my url, driver is ok. Otherwise I would have error in earlier code. Please advice me how to fix it.

1
  • You use the database user "org.postgresql.Driver".... Looks like something is wrong in your database connection configuration. Commented Mar 2, 2015 at 12:19

1 Answer 1

1

I guess this is the method on database you are trying to create database connection from:

def forURL(url:String, user:String = null, password:String = null, prop: Properties = null, driver:String = null): DatabaseDef

As you see it accepts url as first argument, but the second is user (also called role in postgresql) and you're inserting database driver. It accepts that the rest of arguments with defaults (null). You need to provide the rest like this:

val db = Database.forURL(dburl.get, <add username>, <add password>, new Properties, driver.get)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot it worked perfectly. Perhaps I have another related question. I just asked. I believe u may help me again. Link stackoverflow.com/questions/28813624/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.