Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HikariCP Postgresql Driver Claims to not accept JDBC URL

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?

like image 337
user962206 Avatar asked Jan 12 '16 10:01

user962206


People also ask

How connect PostgreSQL to jdbc?

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.

Is PostgreSQL jdbc compliant?

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.


3 Answers

There are a few issues with that URL and a latest PSQL driver may complain.

  1. jdbc:postgres: should be replaced with jdbc:postgresql:
  2. Do not use jdbc:postgresql://<username>:<passwor>..., user parameters instead: jdbc:postgresql://<host>:<port>/<dbname>?user=<username>&password=<password>
  3. In some cases you have to force SSL connection by adding sslmode=require parameter

So 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.

like image 164
Tom Avatar answered Oct 09 '22 16:10

Tom


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

like image 28
Thami Bouchnafa Avatar answered Oct 09 '22 17:10

Thami Bouchnafa


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
like image 8
Jyotirmay Dash Avatar answered Oct 09 '22 18:10

Jyotirmay Dash