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 dat
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"
]
]
}
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:
database.schema
property is optional. It represents the database's namespacedatabase.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