jdbcSession

open override fun jdbcSession(): Connection

Exposes a JDBC connection (session) object using the currently configured database. Applications can use this to execute arbitrary SQL queries (native, direct, prepared, callable) against its Node database tables (including custom contract tables defined by extending net.corda.core.schemas.QueryableState).

When used within a flow, this session automatically forms part of the enclosing flow transaction boundary, and thus queryable data will include everything committed as of the last checkpoint.

We want to make sure users have a restricted access to administrative functions, this function will return a Connection instance with the following methods blocked:

  • abort(executor: Executor?)

  • clearWarnings()

  • close()

  • commit()

  • setSavepoint()

  • setSavepoint(name : String?)

  • releaseSavepoint(savepoint: Savepoint?)

  • rollback()

  • rollback(savepoint: Savepoint?)

  • setCatalog(catalog : String?)

  • setTransactionIsolation(level: Int)

  • setTypeMap(map: MutableMap>?)

  • setHoldability(holdability: Int)

  • setSchema(schema: String?)

  • setNetworkTimeout(executor: Executor?, milliseconds: Int)

  • setAutoCommit(autoCommit: Boolean)

  • setReadOnly(readOnly: Boolean)

Return

A Connection

Throws

if called outside of a transaction.