I've pushed my application to cloudfoundry. However every time I connect to my postgresql/elephant sql I received this error
Driver org.postgresql.Driver claims to not accept JDBC URL jdbc:postgres://cwkqmdql:[email protected]:5432/cwkqmdql/
Is there anything I've missed?
To summarize how you can connect to a PostgreSQL database server, you add the PostgreSQL driver in your classpath. Use DriverManager and provide the connection string, username, and password to connect to the server. You then execute queries using the established connection.
It provides a standard set of interfaces to SQL -compliant databases. PostgreSQL provides a type 4 JDBC driver. Type 4 indicates that the driver is written in Pure Java, and communicates in the database system's own network protocol.
There are a few issues with that URL and a latest PSQL driver may complain.
jdbc:postgres:
should be replaced with jdbc:postgresql:
jdbc:postgresql://<username>:<passwor>...
, user parameters instead: jdbc:postgresql://<host>:<port>/<dbname>?user=<username>&password=<password>
sslmode=require
parameterSo your URL should be:
jdbc:postgresql://@pellefant.db.elephantsql.com:5432/cwkqmdql?user=cwkqmdql&password=SsVqwdLxQObgaJAYu68O-8gTY1VmS9LX
or
jdbc:postgresql://@pellefant.db.elephantsql.com:5432/cwkqmdql?user=cwkqmdql&password=SsVqwdLxQObgaJAYu68O-8gTY1VmS9LX&sslmode=require
I hope that will help.
In my case it was defining the property in double quotes in the java.properties file
by changing
jdbcUrl="url"
to
jdbcUrl=url
it works again
The issue I had was that I had given double quotes for the datasource url in the properties file.
What I had given :
spring.datasource.url="jdbc:postgresql://localhost:5432/postgres"
The correct way to give the url is :
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With