3

I would like to use PostgreSQL instead of H2 as the database for my node. Is using PostgreSQL for Corda nodes possible? How would I configure my node to use a PostgreSQL database?

3 Answers 3

4

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)
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.