KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > api > DatabaseEventListener


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.api;
6
7 import java.sql.SQLException JavaDoc;
8 import java.util.EventListener JavaDoc;
9
10 /**
11  * A class that implements this interface can get notified about exceptions and other events.
12  * A database event listener can be registered when connecting to a database.
13  * Example database URL: jdbc:h2:test;DATABASE_EVENT_LISTENER='com.acme.DbListener' *
14  */

15
16 public interface DatabaseEventListener extends EventListener JavaDoc {
17
18     int STATE_SCAN_FILE = 0, STATE_CREATE_INDEX = 1, STATE_RECOVER = 2;
19
20     /**
21      * This method is called just after creating the object.
22      * This is done when opening the database if the listener is specified in the database URL,
23      * but may be later if the listener is set at runtime with the SET SQL statement.
24      *
25      * @param url - the database URL
26      */

27     void init(String JavaDoc url);
28
29     /**
30      * This method is called if the disk space is very low.
31      *
32      * @param stillAvailable the estimated space that is still available, in bytes
33      * @throws SQLException if the operation should be cancelled
34      */

35     void diskSpaceIsLow(long stillAvailable) throws SQLException JavaDoc;
36
37     /**
38      * This method is called if an exception occured.
39      *
40      * @param e the exception
41      */

42     void exceptionThrown(SQLException JavaDoc e);
43
44     /**
45      * This method is called for long running events, such as recovering, scanning a file or building an index.
46      *
47      * @param state - the state
48      * @param name - the object name
49      * @param x - the current position
50      * @param max - the highest value
51      */

52     void setProgress(int state, String JavaDoc name, int x, int max);
53
54     /**
55      * This method is called before the database is closed normally.
56      */

57     void closingDatabase();
58
59 }
60
Popular Tags