Corda – 缺失的 PostgreSQL 数据库驱动程序 (postgresql-42.2.8.jar)

huangapple go评论80阅读模式
英文:

Corda - postgres database driver (postgresql-42.2.8.jar) missing

问题

我正在使用 corda 4.5,其中 gradle插件版本为5.0.10,并且将postgres作为我的数据库。

当我尝试运行deployNodes任务时,出现以下错误:

[ERROR] 15:51:47+0530 [main] internal.NodeStartupLogging. - 无法找到数据库驱动程序类。请将其添加到驱动程序目录中。[错误代码:database-missing-driver 欲了解更多信息,请访问https://docs.corda.net/docs/corda-os/4.5/error-codes.html] - 无法找到数据库驱动程序类。请将其添加到'drivers'文件夹中。[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版本是多少?

英文:

I am using corda 4.5 with gradle plugin version as 5.0.10 and postgres as my DB.
when I am trying to run deployNodes task, getting below error:

[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]

Following is the deployNode task code in build.gradle file:

    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
}
}

How to add the postgresql jdbc driver path in build.gradle file? What is the compatible postgresql verion with corda 4.5?

答案1

得分: 5

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

cordaDriver "org.postgresql:postgresql:42.2.8"
英文:

It resolved the issue for me by adding the following line in build.gradle file in the dependencies section:

cordaDriver "org.postgresql:postgresql:42.2.8"

答案2

得分: 0

根据这篇文章

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

According to this article:

  1. PostgreSQL 9.6 is the lowest acceptable version, the article uses PostgresSQL 11.
  2. The driver version is postgresql-42.1.4.jar.
  3. In order to point your Gradle task to the driver; create a folder (call it drivers), put the driver's jar file inside of it, then inside extraConfig of your node, add drivers = ['absolute_path_to_directory_with_jdbc_driver'] (notice that it's the absolute path to the directory that you created, not the driver file like you did).
  4. Your node configuration is missing database.transactionIsolationLevel, database.schema, and database.runMigration.
  5. Remove jarDirs and add drivers like I mentioned earlier.

huangapple
  • 本文由 发表于 2020年8月20日 20:19:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/63504964.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定