Package org.h2.samples
Class ShowProgress
- java.lang.Object
-
- org.h2.samples.ShowProgress
-
- All Implemented Interfaces:
java.util.EventListener,DatabaseEventListener
public class ShowProgress extends java.lang.Object implements 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 Constructor Description ShowProgress()Create a new instance of this class, and startNs the timer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclosingDatabase()This method is called when the database is closed.voidexceptionThrown(java.sql.SQLException e, java.lang.String sql)This method is called if an exception occurs in the database.voidinit(java.lang.String url)This method is called just after creating the instance.static voidmain(java.lang.String... args)This 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, java.lang.String name, long current, long max)This method is called when opening the database to notify about the progress.
-
-
-
Method Detail
-
main
public static void main(java.lang.String... args) throws java.lang.ExceptionThis method is called when executing this sample application from the command line.- Parameters:
args- the command line parameters- Throws:
java.lang.Exception- on failure
-
exceptionThrown
public void exceptionThrown(java.sql.SQLException e, java.lang.String sql)This method is called if an exception occurs in the database.- Specified by:
exceptionThrownin interfaceDatabaseEventListener- Parameters:
e- the exceptionsql- the SQL statement
-
setProgress
public void setProgress(int state, java.lang.String name, long current, long max)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
public void init(java.lang.String url)
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
-
-