Package org.h2.samples
Class ShowProgress
java.lang.Object
org.h2.samples.ShowProgress
- All Implemented Interfaces:
EventListener,DatabaseEventListener
This example application implements a database event listener. This is useful
to display progress information while opening a large database, or to log
database exceptions.
-
Field Summary
Fields inherited from interface org.h2.api.DatabaseEventListener
STATE_BACKUP_FILE, STATE_CREATE_INDEX, STATE_RECONNECTED, STATE_RECOVER, STATE_SCAN_FILE, STATE_STATEMENT_END, STATE_STATEMENT_PROGRESS, STATE_STATEMENT_START -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called when the database is closed.voidexceptionThrown(SQLException e, String sql) This method is called if an exception occurs in the database.voidThis method is called just after creating the instance.static voidThis method is called when executing this sample application from the command line.voidopened()This method is called when the database is open.voidsetProgress(int state, String name, long current, long max) This method is called when opening the database to notify about the progress.
-
Constructor Details
-
ShowProgress
public ShowProgress()Create a new instance of this class, and startNs the timer.
-
-
Method Details
-
main
This method is called when executing this sample application from the command line.- Parameters:
args- the command line parameters- Throws:
Exception- on failure
-
exceptionThrown
This method is called if an exception occurs in the database.- Specified by:
exceptionThrownin interfaceDatabaseEventListener- Parameters:
e- the exceptionsql- the SQL statement
-
setProgress
This method is called when opening the database to notify about the progress.- Specified by:
setProgressin interfaceDatabaseEventListener- Parameters:
state- the current statename- the object name (depends on the state)current- the current progressmax- the 100% mark
-
closingDatabase
public void closingDatabase()This method is called when the database is closed.- Specified by:
closingDatabasein interfaceDatabaseEventListener
-
init
This method is called just after creating the instance.- Specified by:
initin interfaceDatabaseEventListener- Parameters:
url- the database URL
-
opened
public void opened()This method is called when the database is open.- Specified by:
openedin interfaceDatabaseEventListener
-