Interface DatabaseAPI
- All Known Implementing Classes:
- DatabaseEngineJDBCImpl
public interface DatabaseAPI
The primary interface to the database. It conceptually represents an SQLite
 database that can have connections opened on it.
- Author:
- Donal Fellows
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceSome code that may be run within a transaction and which will be given a new connection for the duration.static interfaceSome code that may be run within a transaction that returns a result and which will be given a new connection for the duration.static interfaceConnections made by the database engine bean.static interfaceWrapping a prepared query to be more suitable for Java 8 onwards.static interfaceMaps database Row to an object.static interfaceCommon shared API betweenDatabaseAPI.QueryandDatabaseAPI.Update.static interfaceSome code that may be run within a transaction.static interfaceSome code that may be run within a transaction that returns a result.static interfaceWrapping a prepared update to be more suitable for Java 8 onwards.
- 
Method SummaryModifier and TypeMethodDescription<T> Texecute(boolean lockForWriting, DatabaseAPI.ConnectedWithResult<T> operation) A connection manager and transaction runner.default <T> Texecute(DatabaseAPI.ConnectedWithResult<T> operation) A connection manager and transaction runner.voidexecuteVoid(boolean lockForWriting, DatabaseAPI.Connected operation) A connection manager and transaction runner.default voidexecuteVoid(DatabaseAPI.Connected operation) A connection manager and transaction runner.Get a connection.Get a connection to the historical database, similar to the above.booleanWhether the historical data DB is available.
- 
Method Details- 
getConnectionGet a connection. This connection is thread-bound and pooled; it must not be passed to other threads. They should get their own connections instead. The connection has auto-commit disabled; use thetransaction()method instead.- Returns:
- A configured initialised connection to the database.
 
- 
isHistoricalDBAvailableboolean isHistoricalDBAvailable()Whether the historical data DB is available. If it isn't, you can't move any data to longer-term storage, but ordinary operations should be fine.- Returns:
- Whether the historical data DB is available.
 
- 
getHistoricalConnectionGet a connection to the historical database, similar to the above.- Returns:
- A configured initialised connection to the historical database.
 
- 
executeVoidA connection manager and transaction runner. If theoperationcompletes normally (and this isn't a nested use), the transaction commits. If an exception is thrown, the transaction is rolled back. The connection is closed up in any case.- Parameters:
- lockForWriting- Whether to lock for writing. Multiple read locks can be held at once, but only one write lock. Locks cannot be upgraded (because that causes deadlocks).
- operation- The operation to run
- Throws:
- RuntimeException- If something goes wrong with the database access or the contained code.
 
- 
executeVoidA connection manager and transaction runner. If theoperationcompletes normally (and this isn't a nested use), the transaction commits. If an exception is thrown, the transaction is rolled back. The connection is closed up in any case. This uses a write lock.- Parameters:
- operation- The operation to run
- Throws:
- RuntimeException- If something goes wrong with the database access or the contained code.
 
- 
executeA connection manager and transaction runner. If theoperationcompletes normally (and this isn't a nested use), the transaction commits. If an exception is thrown, the transaction is rolled back. The connection is closed up in any case.- Type Parameters:
- T- The type of the result of- operation
- Parameters:
- lockForWriting- Whether to lock for writing. Multiple read locks can be held at once, but only one write lock. Locks cannot be upgraded (because that causes deadlocks).
- operation- The operation to run
- Returns:
- the value returned by operation
- Throws:
- RuntimeException- If something other than database access goes wrong with the contained code.
 
- 
executeA connection manager and transaction runner. If theoperationcompletes normally (and this isn't a nested use), the transaction commits. If an exception is thrown, the transaction is rolled back. The connection is closed up in any case. This uses a write lock.- Type Parameters:
- T- The type of the result of- operation
- Parameters:
- operation- The operation to run
- Returns:
- the value returned by operation
- Throws:
- RuntimeException- If something other than database access goes wrong with the contained code.
 
 
-