0

I just started working with Play Framework in Scala for a school project so I don't know much about the the Framework yet. I'm trying to connect my project to PostgreSql using slick but it is not working. I did exactly the same I have found in the Play website and in many tutorials but it doesn't work.

This is my DB config in the application.conf file

  slick.dbs.default.driver="slick.driver.PostgresDriver$"
  slick.dbs.default.db.driver="org.postgresql.Driver"
  slick.dbs.default.db.url="jdbc:postgresql://localhost:5432/IRProject"
  slick.dbs.default.db.user="<my_username>"
  slick.dbs.default.db.password="<my_password>"

1.sql file in conf/evolutions/default

# --- !Ups

CREATE TABLE Document(
  id SERIAL PRIMARY KEY NOT NULL,
  title VARCHAR(500),
  date TIMESTAMP WITH TIME ZONE,
  url VARCHAR(1000) NOT NULL ,
  path VARCHAR(1000) NOT NULL ,
  summary VARCHAR(5000) NOT NULL

);


# --- !Downs

DROP TABLE IF EXISTS Document;

My dependencies:

  "org.webjars" % "jquery" % "2.1.3",
  "com.typesafe.play" %% "play-slick" % "1.1.1",
  "com.typesafe.play" %% "play-slick-evolutions" % "1.1.1",
  "postgresql" % "postgresql" % "9.1-901.jdbc4"

When I run using activator, I don't see any logs about DB connection or any error at all. The application just starts up but without any tables in the database.

Does any one know a reason for this?

Ken4scholars
  • 6,076
  • 2
  • 21
  • 38

1 Answers1

0

Should anyone come across this problem, these are the solutions I found.

  • I placed the slick db config in the db{} block inside the config file but that is wrong, it should be outside directly inside the config file.
  • I needed to add a test query that can be used to test the connection e.g

    slick.dbs.default.db.connectionTestQuery="SELECT TRUE"

After this it worked.

Ken4scholars
  • 6,076
  • 2
  • 21
  • 38