我已将我的应用程序推送到 Cloud Foundry,但每次连接到我的 PostgreSQL/Elephant SQL 时都会收到此错误。
Driver org.postgresql.Driver claims to not accept JDBC URL jdbc:postgres://cwkqmdql:SsVqwdLxQObgaJAYu68O-8gTY1VmS9LX@pellefant.db.elephantsql.com:5432/cwkqmdql/
我有没有错过什么?
我已将我的应用程序推送到 Cloud Foundry,但每次连接到我的 PostgreSQL/Elephant SQL 时都会收到此错误。
Driver org.postgresql.Driver claims to not accept JDBC URL jdbc:postgres://cwkqmdql:SsVqwdLxQObgaJAYu68O-8gTY1VmS9LX@pellefant.db.elephantsql.com:5432/cwkqmdql/
我有没有错过什么?
该URL存在一些问题,新版本的PSQL驱动程序可能会报错。
jdbc:postgres:
替换为jdbc:postgresql:
jdbc:postgresql://<username>:<passwor>...
,改用用户参数:jdbc:postgresql://<host>:<port>/<dbname>?user=<username>&password=<password>
sslmode=require
参数来强制进行SSL连接。因此,您的URL应该是:
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&sslmode=require
希望这能有所帮助。
jdbc:postgresql://db:5432/
。 - David Groomes在我的情况下,是在java.properties文件中用双引号定义属性
通过更改
jdbcUrl="url"
到
jdbcUrl=url
它再次起作用了
spring.datasource.url="jdbc:postgresql://localhost:5432/postgres"
正确的URL传递方式是:
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
替换
postgresql://localhost/db_name
使用
jdbc:postgresql://localhost/db_name
postgressql
而不是postgresql
。我之前也遇到了相同的错误,后来发现我没有在application.properties类中将我的个人资料设置为活动状态。
spring.profiles.active = dev
我在WebFlux中使用h2 DB时遇到了同样的问题。问题出在spring.datasource.driver
上。
无法工作
spring.datasource.driver=org.h2.Driver
工作中
spring.datasource.driver-class-name=org.h2.Driver
我遇到了同样的错误。 之前在我的 application.properties 中使用了以下内容。我在数据库 URL 前面加了 jdbc:postgres 前缀。
>JDBC_DATABASE_URL=jdbc:postgres://host.com:5432/dbName
我们需要使用PostgreSQL而不是postgres。
>JDBC_DATABASE_URL=jdbc:postgresql://host.com:5432/dbName
src/main/resources
中的 application.properties
src/test/resources
中的 application.yml
src/test/resources
中的 application.yml
更改为 application.properties
后,问题得以解决。
cwkqmdql:SsVqwdLxQObgaJAYu68O-8gTY1VmS9LX
部分应该是用户名和密码,则不能像那样指定它。请参阅手册以获取正确的URL:https://jdbc.postgresql.org/documentation/94/connect.html - user330315