@ProviderType public interface H2DbService extends BaseDbService
H2DbService
instance provides an implementation of BaseDbService
using the H2 database engine.
The Kura core implementation of H2DbService
provides the capability to perform periodic database
defragmentation.
Since H2 currently does not support online defragmentation, the database needs to be shut down to perform the
operation.
Running the defragmentation will cause the existing connections obtained using the
BaseDbService.getConnection()
method to be closed, so applications must be prepared to reopen connections if
necessary.
As an alternative, it is possible to use the withConnection(ConnectionCallable)
method.Modifier and Type | Interface and Description |
---|---|
static interface |
H2DbService.ConnectionCallable<T>
Represents a task that can be executed using the
withConnection(ConnectionCallable) method. |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_INSTANCE_PID |
Modifier and Type | Method and Description |
---|---|
<T> T |
withConnection(H2DbService.ConnectionCallable<T> task)
Executes the provided
H2DbService.ConnectionCallable task on the current thread, and returns the result. |
close, close, close, getConnection, rollback
static final java.lang.String DEFAULT_INSTANCE_PID
<T> T withConnection(H2DbService.ConnectionCallable<T> task) throws java.sql.SQLException
H2DbService.ConnectionCallable
task on the current thread, and returns the result.
It is not necessary to close the Connection
received as argument. If an exception is thrown by the task,
the connection will be rolled back automatically.
This method guarantees that the execution of the provided task will not be affected by the defragmentation
process.
Performing long running operations in the provided tasks might delay the defragmentation
process.task
- the task to be executed.java.sql.SQLException
- if the provided task throws a SQLException
.