DevyDev
DevyDev

Reputation: 33

issue trying to connect my playframework slick application with a postgres database runing in docker

here is my docker compose:

  db:
    image: postgres
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=admin
    ports:
      - '5432:5432'
    volumes:
      - db:/var/lib/postgresql11/data
      - ./db/init-scripts.sql:/docker-entrypoint-initdb.d/scripts.sql

volumes:
  db:
    driver: local

here is my config in my application

slick.dbs.default.profile="slick.jdbc.H2Profile$"
slick.dbs.default.db.driver="org.h2.Driver"
slick.dbs.default.db.url="jdbc:postgresql://localhost:5432/postgressslmode=require"
slick.dbs.default.db.user="postgres"
slick.dbs.default.db.password="admin"

I am currently recieving this stack trace:

[CreationException: Unable to create injector, see the following errors:

1) [Guice/ErrorInCustomProvider]: RuntimeException: Driver Driver claims to not accept jdbcUrl, jdbc:postgresql://localhost:5432/postgressslmode=require
  while locating ApplicationEvolutionsProvider
  at EvolutionsModule.<init>(EvolutionsModule.scala:23):
Binding(class ApplicationEvolutions to ProviderConstructionTarget(class ApplicationEvolutionsProvider) eagerly)
      \_ installed by: Modules$OverrideModule -> GuiceableModuleConversions$$anon$4
  while locating ApplicationEvolutions

Learn more:
  https://github.com/google/guice/wiki/ERROR_IN_CUSTOM_PROVIDER

1 error

======================
Full classname legend:
======================
ApplicationEvolutions:              "play.api.db.evolutions.ApplicationEvolutions"
ApplicationEvolutionsProvider:      "play.api.db.evolutions.ApplicationEvolutionsProvider"
Driver:                             "org.h2.Driver"
EvolutionsModule:                   "play.api.db.evolutions.EvolutionsModule"
GuiceableModuleConversions$$anon$4: "play.api.inject.guice.GuiceableModuleConversions$$anon$4"
Modules$OverrideModule:             "com.google.inject.util.Modules$OverrideModule"
========================
End of classname legend:
========================
]

I have been looking at the slick documentation but see how the url does not match what is expected - is there some special syntax i am missing?

Upvotes: 0

Views: 36

Answers (1)

Ga&#235;l J
Ga&#235;l J

Reputation: 15275

You're using a driver for H2 database (slick.dbs.default.db.driver="org.h2.Driver") but trying to connect to a PostgreSQL database according to the JDBC URL.

Either use a H2 URL with H2 driver, or Postgres URL with Postgres driver.

Upvotes: 0

Related Questions