Class ShowProgress

java.lang.Object
org.h2.samples.ShowProgress
All Implemented Interfaces:
EventListener, DatabaseEventListener

public class ShowProgress extends 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.
  • Constructor Details

    • ShowProgress

      public ShowProgress()
      Create a new instance of this class, and startNs the timer.
  • Method Details

    • main

      public static void main(String... args) throws Exception
      This method is called when executing this sample application from the command line.
      Parameters:
      args - the command line parameters
      Throws:
      Exception - on failure
    • exceptionThrown

      public void exceptionThrown(SQLException e, 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, String name, long current, long 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(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