Node database

Configuring the node database

H2

By default, nodes store their data in an H2 database. See Database access when running H2.

PostgreSQL

Nodes can also be configured to use PostgreSQL 9.6, using PostgreSQL JDBC Driver 42.2.8. However, this is an experimental community contribution. The Corda continuous integration pipeline does not run unit tests or integration tests of this databases.

Here is an example node configuration for PostgreSQL:

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

Note that:

  • Database schema name can be set in JDBC URL string e.g. currentSchema=my_schema
  • Database schema name must either match the dataSource.user value to end up on the standard schema search path according to the PostgreSQL documentation, or the schema search path must be set explicitly for the user.
  • If your PostgresSQL database is hosting multiple schema instances (using the JDBC URL currentSchema=my_schema) for different Corda nodes, you will need to create a hibernate_sequence sequence object manually for each subsequent schema added after the first instance. Corda doesn’t provision Hibernate with a schema namespace setting and a sequence object may be not created. Run the DDL statement and replace my_schema with your schema namespace:
CREATE SEQUENCE my_schema.hibernate_sequence INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 8 CACHE 1 NO CYCLE;
  • The PostgreSQL JDBC database driver must be placed in the drivers directory in the node.

SQLServer

Nodes also have untested support for Microsoft SQL Server 2017, using Microsoft JDBC Driver 6.4 for SQL Server. Here is an example node configuration for SQLServer:

dataSourceProperties = {
    dataSourceClassName = "com.microsoft.sqlserver.jdbc.SQLServerDataSource"
    dataSource.url = "jdbc:sqlserver://[HOST]:[PORT];databaseName=[DATABASE_NAME]"
    dataSource.user = [USER]
    dataSource.password = [PASSWORD]
}
database = {
    transactionIsolationLevel = READ_COMMITTED
}
jarDirs = ["[FULL_PATH]/sqljdbc_6.4/enu/"]

Note that:

  • Ensure the directory referenced by jarDirs contains only one JDBC driver JAR file; by default, the sqljdbc_6.4/enu/ contains multiple JDBC JAR files for different Java versions.

Node database tables

By default, the node database has the following tables:

Table nameColumns
DATABASECHANGELOGID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, EXECTYPE, MD5SUM, DESCRIPTION, COMMENTS, TAG, LIQUIBASE, CONTEXTS, LABELS, DEPLOYMENT_ID
DATABASECHANGELOGLOCKID, LOCKED, LOCKGRANTED, LOCKEDBY
NODE_ATTACHMENTSATT_ID, CONTENT, FILENAME, INSERTION_DATE, UPLOADER, VERSION
NODE_ATTACHMENTS_CONTRACTSATT_ID, CONTRACT_CLASS_NAME
NODE_ATTACHMENTS_SIGNERSATT_ID, SIGNER
NODE_CHECKPOINTSCHECKPOINT_ID, CHECKPOINT_VALUE
NODE_CONTRACT_UPGRADESSTATE_REF, CONTRACT_CLASS_NAME
NODE_HASH_TO_KEYPK_HASH, PUBLIC_KEY
NODE_IDENTITIESPK_HASH, IDENTITY_VALUE
NODE_IDENTITIES_NO_CERTPK_HASH, NAME
NODE_INFOSNODE_INFO_ID, NODE_INFO_HASH, PLATFORM_VERSION, SERIAL
NODE_INFO_HOSTSHOST_NAME, PORT, NODE_INFO_ID, HOSTS_ID
NODE_INFO_PARTY_CERTPARTY_NAME, ISMAIN, OWNING_KEY_HASH, PARTY_CERT_BINARY
NODE_LINK_NODEINFO_PARTYNODE_INFO_ID, PARTY_NAME
NODE_MESSAGE_IDSMESSAGE_ID, INSERTION_TIME, SENDER, SEQUENCE_NUMBER
NODE_NAMED_IDENTITIESNAME, PK_HASH
NODE_NETWORK_PARAMETERSHASH, EPOCH, PARAMETERS_BYTES, SIGNATURE_BYTES, CERT, PARENT_CERT_PATH
NODE_OUR_KEY_PAIRSPUBLIC_KEY_HASH, PRIVATE_KEY, PUBLIC_KEY
NODE_PROPERTIESPROPERTY_KEY, PROPERTY_VALUE
NODE_SCHEDULED_STATESOUTPUT_INDEX, TRANSACTION_ID, SCHEDULED_AT
NODE_TRANSACTIONSTX_ID, TRANSACTION_VALUE, STATE_MACHINE_RUN_ID, STATUS
PK_HASH_TO_EXT_ID_MAPEXTERNAL_ID, PUBLIC_KEY_HASH
STATE_PARTYOUTPUT_INDEX, TRANSACTION_ID, PUBLIC_KEY_HASH, X500_NAME
VAULT_FUNGIBLE_STATESOUTPUT_INDEX, TRANSACTION_ID, ISSUER_NAME, ISSUER_REF, OWNER_NAME, QUANTITY
VAULT_FUNGIBLE_STATES_PARTSOUTPUT_INDEX, TRANSACTION_ID, PARTICIPANTS
VAULT_LINEAR_STATESOUTPUT_INDEX, TRANSACTION_ID, EXTERNAL_ID, UUID
VAULT_LINEAR_STATES_PARTSOUTPUT_INDEX, TRANSACTION_ID, PARTICIPANTS
VAULT_STATESOUTPUT_INDEX, TRANSACTION_ID, CONSUMED_TIMESTAMP, CONTRACT_STATE_CLASS_NAME, LOCK_ID, LOCK_TIMESTAMP, NOTARY_NAME, RECORDED_TIMESTAMP, STATE_STATUS, RELEVANCY_STATUS, CONSTRAINT_TYPE, CONSTRAINT_DATA
VAULT_TRANSACTION_NOTESSEQ_NO, NOTE, TRANSACTION_ID
V_PKEY_HASH_EX_ID_MAPPUBLIC_KEY_HASH, TRANSACTION_ID, OUTPUT_INDEX, EXTERNAL_ID

For more details see: Database tables.

Database connection pool

Corda uses Hikari Pool for creating the connection pool. To configure the connection pool any custom properties can be set in the dataSourceProperties section.

For example:

dataSourceProperties = {
    dataSourceClassName = "org.postgresql.ds.PGSimpleDataSource"
    ...
    maximumPoolSize = 10
    connectionTimeout = 50000
}