Using PostgreSQL instead of H2 as the Corda node's database

扶醉桌前 提交于 2019-11-29 02:44:25
Joel

Both Corda 2 and Corda 3 allow the use of PostgreSQL 9.6, using PostgreSQL JDBC Driver 42.1.4. Note that this is an experimental community contribution, and is currently untested.

Here is an example node configuration block for PostgreSQL:

dataSourceProperties = {
    dataSourceClassName = "org.postgresql.ds.PGSimpleDataSource"
    dataSource.url = "jdbc:postgresql://[HOST]:[PORT]/postgres"
    dataSource.user = [USER]
    dataSource.password = [PASSWORD]
}

database = {
    transactionIsolationLevel = READ_COMMITTED
    schema = [SCHEMA]
}

You need to add this block to the node's node.conf file, found at the root of the node folder.

Note that:

  • The database.schema property is optional. It represents the database's namespace
  • The value of database.schema is not wrapped in double quotes and Postgres always treats it as a lower-case value (e.g. AliceCorp becomes alicecorp)

Please specify the version you are working on, to my understanding you can do this if you build Corda v3.0 from master. You can in fact specify Jars to be loaded in Corda and your custom jdbc connection string, please refer to the updated documentation about Node configuration: https://docs.corda.net/head/corda-configuration-file.html

You can add the Postgresql DB properties to your node config in build.gradle script using extraConfig=[ ... ] block is shown as below.

node {

    ...

    extraConfig = [
        dataSourceProperties: [
                dataSourceClassName : "org.postgresql.ds.PGSimpleDataSource",
                'dataSource.url' : "jdbc:postgresql://localhost:5432/nodedb",
                'dataSource.user' : "postgres",
                'dataSource.password' : "pa$$w0rd"
        ],
        database: [
                transactionIsolationLevel : "READ_COMMITTED"
        ]
    ]
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!