【问题标题】:How to integrate PostgreSQL with Corda 3.0 or with Corda 4.0?如何将 PostgreSQL 与 Corda 3.0 或 Corda 4.0 集成?
【发布时间】:2019-04-15 14:29:13
【问题描述】:

我尝试在 Corda 3.0 和 Corda 4.0 中将 PostgreSQL 配置为节点的数据库。 我在 build.gradle 文件中添加了以下内容。 (Testdb1 是数据库名称。我也尝试过使用 postgres)

node{
...
    // this part i have added
    extraConfig = [
        jarDirs: ['path'],
            'dataSourceProperties': [
                    'dataSourceClassName': 'org.postgresql.ds.PGSimpleDataSource',
                    '"dataSource.url"'     : 'jdbc:postgresql://127.0.0.1:5432/Testdb1',
                    '"dataSource.user"'    : 'postgres',
                    '"dataSource.password"': 'admin@123'
            ],
            'database': [
                    'transactionIsolationLevel': 'READ_COMMITTED'
            ]
    ]
    // till here
}

reference.conf 文件中的这部分

dataSourceProperties = {
    dataSourceClassName = org.postgresql.ds.PGSimpleDataSource
    dataSource.url = "jdbc:postgresql://127.0.0.1:5432/Testdb1"
    dataSource.user = postgres
    dataSource.password = "admin@123"
}
database = {
    transactionIsolationLevel = "READ_COMMITTED"
}
jarDirs = ["path"]

部署节点时出现以下错误:

FAILURE: Build failed with an exception.
            * What went wrong:
            Execution failed for task ':java-source:deployNodes'.

在 node-info-gen.log 文件中显示了 CAPSULE EXCEPTION。然后我将我的 JDK 更新为 8u191,但仍然出现同样的错误。

我已经完成了以下工作。可以从这里得到参考。 https://docs.corda.net/node-database.html , https://github.com/corda/corda/issues/4037 , How can the Corda node be extended to work with databases other than H2?

【问题讨论】:

    标签: postgresql corda


    【解决方案1】:

    您需要在每个 Corda 节点的 node.conf 中添加这些属性。在你做“deployNodes”之后

    在 node.conf 文件中添加这些属性后,只需运行 corda jar 即可。它会自动启动。但在此之前,您需要创建表(corda 文档中已经提供了到其他数据库的迁移)

    【讨论】:

      【解决方案2】:

      我在每个节点的 .conf 文件和一个 referene.conf 文件中添加了以下内容。我已经为用户 postgres 授予了corda文档中提到的所有权限。 https://docs.corda.r3.com/node-database.html

      (之前我使用了 postgresql-42.2.5.jar 文件,但没有成功,所以我使用了它的一个降级版本 postgresql-42.1.4.jar . 可以从https://jdbc.postgresql.org/download.html下载jar文件)

      部署节点成功后添加以下内容:

      dataSourceProperties = {
          dataSourceClassName = org.postgresql.ds.PGSimpleDataSource
          dataSource.url = "jdbc:postgresql://127.0.0.1:5432/Testdb1"
          dataSource.user = postgres
          dataSource.password = "admin@123"
      }
      database = {
          transactionIsolationLevel = "READ_COMMITTED"
      }
      jarDirs = ["path"]
      

      (路径 = jar 文件的位置)添加此配置运行文件后称为 runnodes.bat

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-07-03
        • 2020-02-17
        • 1970-01-01
        • 2019-12-16
        • 2019-04-24
        • 2021-08-18
        • 2019-07-31
        相关资源
        最近更新 更多