Java HikariCP Postgresql 驱动程序声称不接受 JDBC URL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34741443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 15:56:08  来源:igfitidea点击:

HikariCP Postgresql Driver Claims to not accept JDBC URL

javapostgresqljdbccloudfoundryhikaricp

提问by user962206

I've pushed my application to cloudfoundry. However every time I connect to my postgresql/elephant sql I received this error

我已将我的应用程序推送到 cloudfoundry。但是,每次我连接到我的 postgresql/elephant sql 时,我都会收到此错误

 Driver org.postgresql.Driver claims to not accept JDBC URL jdbc:postgres://cwkqmdql:[email protected]:5432/cwkqmdql/

Is there anything I've missed?

有什么我错过了吗?

回答by Tom

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

该 URL 存在一些问题,最新的 PSQL 驱动程序可能会抱怨。

  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=requireparameter
  1. jdbc:postgres:应该替换为 jdbc:postgresql:
  2. 不要使用jdbc:postgresql://<username>:<passwor>..., 用户参数:jdbc:postgresql://<host>:<port>/<dbname>?user=<username>&password=<password>
  3. 在某些情况下,您必须通过添加sslmode=require参数来强制 SSL 连接

So your URL should be:

所以你的网址应该是:

jdbc:postgresql://@pellefant.db.elephantsql.com:5432/cwkqmdql?user=cwkqmdql&password=SsVqwdLxQObgaJAYu68O-8gTY1VmS9LX

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

jdbc:postgresql://@pellefant.db.elephantsql.com:5432/cwkqmdql?user=cwkqmdql&password=SsVqwdLxQObgaJAYu68O-8gTY1VmS9LX&sslmode=require

I hope that will help.

我希望这会有所帮助。

回答by Thami Bouchnafa

In my case it was defining the property in double quotes in the java.properties file

就我而言,它是在 java.properties 文件中用双引号定义属性

by changing

通过改变

jdbcUrl="url"

to

jdbcUrl=url

it works again

它又起作用了