corda-postgres数据库驱动程序(postgresql-42.2.8.jar)

dxxyhpgq  于 2021-07-09  发布在  Java
关注(0)|答案(2)|浏览(476)

我使用corda4.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", "password": "user123", "permissions": ["ALL"]]]
        //new DB config
        //DB
        extraConfig = [
                'dataSourceProperties.dataSource.url' : 'jdbc:postgresql://localhost:5432/egdb?currentSchema=nodeB_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

    }
}

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

xcitsw88

xcitsw881#

根据这篇文章:
postgresql9.6是可接受的最低版本,本文使用postgresql11。
驱动程序版本是postgresql-42.1.4.jar。
为了把你的任务交给司机;创建一个文件夹(称之为 drivers ),将驱动程序的jar文件放入其中,然后放入 extraConfig 在节点的 drivers = ['absolute_path_to_directory_with_jdbc_driver'] (请注意,它是您创建的目录的绝对路径,而不是像您那样的驱动程序文件)。
缺少节点配置 database.transactionIsolationLevel , database.schema ,和 database.runMigration .
删除 jarDirs 并添加 drivers 就像我之前提到的。

olhwl3o2

olhwl3o22#

它为我解决了这个问题,在 build.gradle 依赖项部分中的文件:

cordaDriver "org.postgresql:postgresql:42.2.8"

相关问题