【问题标题】:liquibase generateChangeLog Connection could not be created to jdbc:postgresliquibase generateChangeLog 无法创建与 jdbc:postgres 的连接
【发布时间】:2019-09-02 16:55:57
【问题描述】:

我正在尝试运行 liquibase 以生成我当前数据库的变更日志,但我收到以下错误并且不知道如何解决它。

Unexpected error running Liquibase: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgres://kbjoxiifqvunac:ef1f6ba0b9633d5951c6f4a28897fe390fdf2a7f4189320569d303531899e843@ec2-54-217-235-159.eu-west-1.compute.amazonaws.com:5432/d1pdhars1kb6ep with driver org.postgresql.Driver.  Possibly the wrong driver for the given database URL
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgres://kbjoxiifqvunac:ef1f6ba0b9633d5951c6f4a28897fe390fdf2a7f4189320569d303531899e843@ec2-54-217-235-159.eu-west-1.compute.amazonaws.com:5432/d1pdhars1kb6ep with driver org.postgresql.Driver.  Possibly the wrong driver for the given database URL
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:135) ~[liquibase.jar:na]
        at liquibase.integration.commandline.Main.doMigration(Main.java:977) [liquibase.jar:na]
        at liquibase.integration.commandline.Main.run(Main.java:209) [liquibase.jar:na]
        at liquibase.integration.commandline.Main.main(Main.java:132) [liquibase.jar:na]
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgres://kbjoxiifqvunac:ef1f6ba0b9633d5951c6f4a28897fe390fdf2a7f4189320569d303531899e843@ec2-54-217-235-159.eu-west-1.compute.amazonaws.com:5432/d1pdhars1kb6ep with driver org.postgresql.Driver.  Possibly the wrong driver for the given database URL
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:259) ~[liquibase.jar:na]
        at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:149) ~[liquibase.jar:na]
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:100) ~[liquibase.jar:na]
        ... 3 common frames omitted
Caused by: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgres://kbjoxiifqvunac:ef1f6ba0b9633d5951c6f4a28897fe390fdf2a7f4189320569d303531899e843@ec2-54-217-235-159.eu-west-1.compute.amazonaws.com:5432/d1pdhars1kb6ep with driver org.postgresql.Driver.  Possibly the wrong driver for the given database URL
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:254) ~[liquibase.jar:na]
        ... 5 common frames omitted

我已经运行了以下命令

liquibase --driver=org.postgresql.Driver --changeLogFile=changelog.xml --url=jdbc:postgres://user:password@ec2-54-217-235-159.eu-west-1.compute.amazonaws.com:5432/dbhost generateChangeLog

我省略了类路径标志,因为我将 postgres 驱动程序放在我的 liquibase 的 lib 文件夹中,并且根据文档它应该扫描它。

我在 Windows、liquibase 版本 3.8.0 和 postgres-drivers 42.1.1 上运行。有任何想法吗?在此先感谢您的帮助

【问题讨论】:

    标签: liquibase


    【解决方案1】:

    我认为您的驱动程序 jar 应该在 lib 目录而不是 bin 目录中。如果您从liquibase.bat 中查看这些行,您可以看到它在bin 目录中添加了所有以liquibase 开头的jar 文件,然后是ALL jar lib 目录中的文件。

    set CP=.
    for /R %LIQUIBASE_HOME% %%f in (liquibase*.jar) do set CP=!CP!;%%f
    for /R %LIQUIBASE_HOME%\lib %%f in (*.jar) do set CP=!CP!;%%f
    

    【讨论】:

    • 是我的错,已经在lib文件夹里了,我写帖子的时候出错了
    猜你喜欢
    • 1970-01-01
    • 2018-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-28
    • 2021-02-13
    相关资源
    最近更新 更多