org.h2.samples
Class ShowProgress

java.lang.Object
  extended by 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
 
Constructor Summary
ShowProgress()
          Create a new instance of this class, and start the timer.
 
Method Summary
 void closingDatabase()
          This method is called when the database is closed.
 void exceptionThrown(java.sql.SQLException e, java.lang.String sql)
          This method is called if an exception occurs in the database.
 void init(java.lang.String url)
          This method is called just after creating the instance.
static void main(java.lang.String... args)
          This method is called when executing this sample application from the command line.
 void opened()
          This method is called when the database is open.
 void setProgress(int state, java.lang.String name, int current, int max)
          This method is called when opening the database to notify about the progress.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShowProgress

public ShowProgress()
Create a new instance of this class, and start the timer.

Method Detail

main

public static void main(java.lang.String... args)
                 throws java.lang.Exception
This method is called when executing this sample application from the command line.

Parameters:
args - the command line parameters
Throws:
java.lang.Exception

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:
exceptionThrown in interface DatabaseEventListener
Parameters:
e - the exception
sql - the SQL statement

setProgress

public void setProgress(int state,
                        java.lang.String name,
                        int current,
                        int max)
This method is called when opening the database to notify about the progress.

Specified by:
setProgress in interface DatabaseEventListener
Parameters:
state - the current state
name - the object name (depends on the state)
current - the current progress
max - the 100% mark

closingDatabase

public void closingDatabase()
This method is called when the database is closed.

Specified by:
closingDatabase in interface DatabaseEventListener

init

public void init(java.lang.String url)
This method is called just after creating the instance.

Specified by:
init in interface DatabaseEventListener
Parameters:
url - the database URL

opened

public void opened()
This method is called when the database is open.

Specified by:
opened in interface DatabaseEventListener