Corda-Postgres数据库驱动程序postgresql-42.2.8.jar丢失

问题描述

我正在使用 corda 4.5 gradle插件版本为5.0.10 ,并使用 postgres 作为我的数据库。 当我尝试运行deployNodes任务时,出现以下错误:

[ERROR] 15:51:47+0530 [main] internal.NodeStartupLogging. - Could not find the database driver class. Please add it to the drivers directory. [Error Code: database-missing-driver For further information,please go to https://docs.corda.net/docs/corda-os/4.5/error-codes.html] - Could not find the database driver class. Please add it to the 'drivers' folder. [errorCode=1oswgkz,moreInformationAt=https://errors.corda.net/OS/4.5/1oswgkz]

以下是build.gradle文件中的deployNode任务代码:

    task deployNodes(type: net.corda.plugins.Cordform,dependsOn: ['jar']) {
    nodeDefaults {
        projectCordapp {
            deploy = false
        }
        cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version"
        cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version"
        cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version"

        cordapp project(':cordapp-contracts-states')
        cordapp project(':workflows')

        //ext.drivers = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
    }

    //NOTARY NODE

    node {
        name "O=Notary,L=London,C=GB"
        notary = [validating: true]
        p2pAddress("localhost:10002")
        rpcSettings {
            address("localhost:10003")
            adminAddress("localhost:10043")
        }
    }

    // NODEA

    node {
        name "O=NODEA,L=Lucknow,C=IN"

        p2pAddress("localhost:10010")
        rpcSettings {
            address("localhost:10011")
            adminAddress("localhost:10052")
        }
        rpcUsers = [[user: "userA","password": "user123","permissions": ["ALL"]]]
        //new DB config
        //DB
        extraConfig = [
                'dataSourceProperties.dataSource.url' : 'jdbc:postgresql://localhost:5432/egdb?currentSchema=nodeA_schema','dataSourceProperties.dataSourceClassName' : 'org.postgresql.ds.PGSimpleDataSource','dataSourceProperties.dataSource.user' : 'postgres','dataSourceProperties.dataSource.password' : 'postgres',//'dataSourceProperties.driverClassName' : 'org.postgresql.ds.PGSimpleDataSource'
                //jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
                //'drivers' : 'org.postgresql.Driver'
                'jarDirs' : ['${rootProject.projectDir}/lib/jdbc/driver/postgresql-42.2.8.jar']
        ]
        //jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
        //drivers = ext.drivers

    }

// NODEB
 node {
        name "O=NODEB,L=Delhi,C=IN"

        p2pAddress("localhost:10010")
        rpcSettings {
            address("localhost:10011")
            adminAddress("localhost:10052")
        }
        rpcUsers = [[user: "userB","permissions": ["ALL"]]]
        //new DB config
        //DB
        extraConfig = [
                'dataSourceProperties.dataSource.url' : 'jdbc:postgresql://localhost:5432/egdb?currentSchema=nodeB_schema',//'dataSourceProperties.driverClassName' : 'org.postgresql.ds.PGSimpleDataSource'
                //jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
                //'drivers' : 'org.postgresql.Driver'
                'jarDirs' : ['${rootProject.projectDir}/lib/jdbc/driver/postgresql-42.2.8.jar']
        ]
        //jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
        //drivers = ext.drivers

    }
}

如何在build.gradle文件中添加postgresql jdbc驱动程序路径?什么是与corda 4.5兼容的postgresql版本?

解决方法

它通过在依赖项部分的build.gradle文件中添加以下行来为我解决了该问题:

cordaDriver "org.postgresql:postgresql:42.2.8"
,

根据this article

  1. PostgreSQL 9.6是最低可接受的版本,本文使用PostgresSQL 11。
  2. 驱动程序版本为postgresql-42.1.4.jar。
  3. 为了将Gradle任务指向驱动程序;创建一个文件夹(称为drivers),将驱动程序的jar文件放入其中,然后在节点的extraConfig内,添加drivers = ['absolute_path_to_directory_with_jdbc_driver'](注意,这是您创建的目录,而不是像以前那样创建驱动程序文件
  4. 您的节点配置缺少database.transactionIsolationLeveldatabase.schemadatabase.runMigration
  5. 像我之前提到的那样删除jarDirs并添加drivers

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...