org.h2.api
Interface DatabaseEventListener

All Superinterfaces:
java.util.EventListener

public interface DatabaseEventListener
extends java.util.EventListener

A class that implements this interface can get notified about exceptions and other events. A database event listener can be registered when connecting to a database. Example database URL: jdbc:h2:test;DATABASE_EVENT_LISTENER='com.acme.DbListener'


Field Summary
static int STATE_BACKUP_FILE
          This state is used during the BACKUP command.
static int STATE_CREATE_INDEX
          This state is used when re-creating an index.
static int STATE_RECONNECTED
          This state is used after re-connecting to a database (if auto-reconnect is enabled).
static int STATE_RECOVER
          This state is used when re-applying the transaction log or rolling back uncommitted transactions.
static int STATE_SCAN_FILE
          This state is used when scanning the database file.
 
Method Summary
 void closingDatabase()
          This method is called before the database is closed normally.
 void diskSpaceIsLow()
          This method is called if the disk space is very low.
 void exceptionThrown(java.sql.SQLException e, java.lang.String sql)
          This method is called if an exception occurred.
 void init(java.lang.String url)
          This method is called just after creating the object.
 void opened()
          This method is called after the database has been opened.
 void setProgress(int state, java.lang.String name, int x, int max)
          This method is called for long running events, such as recovering, scanning a file or building an index.
 

Field Detail

STATE_SCAN_FILE

static final int STATE_SCAN_FILE
This state is used when scanning the database file.

See Also:
Constant Field Values

STATE_CREATE_INDEX

static final int STATE_CREATE_INDEX
This state is used when re-creating an index.

See Also:
Constant Field Values

STATE_RECOVER

static final int STATE_RECOVER
This state is used when re-applying the transaction log or rolling back uncommitted transactions.

See Also:
Constant Field Values

STATE_BACKUP_FILE

static final int STATE_BACKUP_FILE
This state is used during the BACKUP command.

See Also:
Constant Field Values

STATE_RECONNECTED

static final int STATE_RECONNECTED
This state is used after re-connecting to a database (if auto-reconnect is enabled).

See Also:
Constant Field Values
Method Detail

init

void init(java.lang.String url)
This method is called just after creating the object. This is done when opening the database if the listener is specified in the database URL, but may be later if the listener is set at runtime with the SET SQL statement.

Parameters:
url - - the database URL

opened

void opened()
This method is called after the database has been opened. It is save to connect to the database and execute statements at this point.


diskSpaceIsLow

void diskSpaceIsLow()
This method is called if the disk space is very low. One strategy is to inform the user and wait for it to clean up disk space. The database should not be accessed from within this method (even to close it).


exceptionThrown

void exceptionThrown(java.sql.SQLException e,
                     java.lang.String sql)
This method is called if an exception occurred.

Parameters:
e - the exception
sql - the SQL statement

setProgress

void setProgress(int state,
                 java.lang.String name,
                 int x,
                 int max)
This method is called for long running events, such as recovering, scanning a file or building an index.

Parameters:
state - the state
name - the object name
x - the current position
max - the highest value

closingDatabase

void closingDatabase()
This method is called before the database is closed normally. It is save to connect to the database and execute statements at this point, however the connection must be closed before the method returns.