Cannot connect PostgreSQL to Java project (Ebean, JDBC)
Hello there, I'm trying to connect Railway PostgreSQL DB to my Java+Ebean project. I get this error:
io.ebean.datasource.DataSourceInitialiseException: Error initialising DataSource with user: postgres url:jdbc:postgresql://containers-us-west-79.railway.app:7512/railway error:No suitable driver found for jdbc:postgresql://containers-us-west-79.railway.app:7512/railway
I see that it needs a driver, but everything seems to be fine locally and I've added dependencies to Gradle build (implementation("org.postgresql:postgresql:42.6.0"
). I've created variable "URL to DB" like this: jdbc:postgresql://${{Postgres.PGHOST}}:${{Postgres.PGPORT}}/${{Postgres.PGDATABASE}}
When I use same variables locally I can successfully connect to remote DB, but during deployment process previously mentioned error occurs.Solution:Jump to solution
Yeah, thanks. Solved it, here's solution:
1) Need both gradle dependencies:
implementation("org.postgresql:postgresql:42.6.0")
implementation("io.ebean:ebean-platform-postgres:13.15.0")
2) either add driver: org.postgresql.Driver
to application.yaml
or add Class.forName("org.postgresql.Driver");
to the main code....5 Replies
Project ID:
3325ddb9-c1d0-4a0e-b3db-4049808548fe
3325ddb9-c1d0-4a0e-b3db-4049808548fe
did you check the documentation and try the steps given there:
https://jdbc.postgresql.org/documentation/use/
Solution
Yeah, thanks. Solved it, here's solution:
1) Need both gradle dependencies:
implementation("org.postgresql:postgresql:42.6.0")
implementation("io.ebean:ebean-platform-postgres:13.15.0")
2) either add driver: org.postgresql.Driver
to application.yaml
or add Class.forName("org.postgresql.Driver");
to the main code.