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
HikariCP Postgresql Driver Claims to not accept JDBC URL
提问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 驱动程序可能会抱怨。
jdbc:postgres:
should be replaced withjdbc:postgresql:
- Do not use
jdbc:postgresql://<username>:<passwor>...
, user parameters instead:jdbc:postgresql://<host>:<port>/<dbname>?user=<username>&password=<password>
- In some cases you have to force SSL connection by adding
sslmode=require
parameter
jdbc:postgres:
应该替换为jdbc:postgresql:
- 不要使用
jdbc:postgresql://<username>:<passwor>...
, 用户参数:jdbc:postgresql://<host>:<port>/<dbname>?user=<username>&password=<password>
- 在某些情况下,您必须通过添加
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
它又起作用了