Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Play an JDBC with Postgresql?

Here is my postgres version postgresql/9.4.1

Here is my play version addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")

Here is my libraryDependencies

libraryDependencies ++= Seq(
  jdbc,
  cache,
  ws,
  specs2 % Test,
  "postgresql" % "postgresql" % "9.1-901-1.jdbc4"

)

Changing version to 9.4-1201-jdbc41 gives sbt.ResolveException: unresolved dependency: postgresql#postgresql;9.4-1201-jdbc41: not found

Here is my application.conf

db.default.driver=org.postgresql.Driver
# I tried the following combination
#db.default.url="postgres://user:pass@localhost/20160210_scala_play"

# And

db.default.url="jdbc:postgresql://localhost/20160210_scala_play"
db.default.user="user"
db.default.password="pass"

All resulted in

`Cannot connect to database`

I verified that

psql \list

does contain

20160210_scala_play

with user=user password=password

Can someone point me a direction?

like image 617
Kevin Avatar asked Sep 18 '25 22:09

Kevin


1 Answers

By default, postgresql will listen to port 5432. So, Unless you sure about the fact that your postgre instance is running on port 80, change your JDBC url to:

jdbc:postgresql://localhost:5432/20160210_scala_play

And also, this dependency was resolved for me:

"org.postgresql" % "postgresql" % "9.4-1206-jdbc42"
like image 162
Ali Dehghani Avatar answered Sep 22 '25 08:09

Ali Dehghani