MockServices.jdbcSession - corda

corda / net.corda.testing.node / MockServices / jdbcSession

# jdbcSession

`open 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 RestrictedConnection instance. The following methods are 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<String, Class<*>>?)
- setHoldability(holdability: Int)
- setSchema(schema: String?)
- setNetworkTimeout(executor: Executor?, milliseconds: Int)
- setAutoCommit(autoCommit: Boolean)
- setReadOnly(readOnly: Boolean)

### Exceptions

`IllegalStateException` - if called outside of a transaction.

Return
A Connection