Is database closed when Connection.close() returns?

14 views
Skip to first unread message

Bruno Nyffeler

unread,
Nov 10, 2008, 10:06:37 AM11/10/08
to H2 Database
Hello,

I got a database with one open connection. If I call close() will the
database be closed for good after the call returns? Or is it an
asynchronous call?

I need to be notified as soon as the database has definitely finished.
Should I be using the CloseListener?

Thanks,

Bruno

Thomas Mueller

unread,
Nov 11, 2008, 4:08:44 PM11/11/08
to h2-da...@googlegroups.com
Hi,

> I got a database with one open connection. If I call close() will the
> database be closed for good after the call returns?

By default, yes, the database is closed when the last connection is
closed. You can prevent that using the DB_CLOSE_DELAY, see also
http://www.h2database.com/html/grammar.html#setdbclosedelay

> I need to be notified as soon as the database has definitely finished.
> Should I be using the CloseListener?

If you still need this feature, then you could use the
DatabaseEventListener, see
http://www.h2database.com/javadoc/org/h2/api/DatabaseEventListener.html
- the CloseListener is currently only used for triggers (see the
javadocs).

Regards,
Thomas

Bruno Nyffeler

unread,
Nov 12, 2008, 11:03:29 AM11/12/08
to H2 Database
Hi Thomas,

No, that should be sufficient. I just need to make sure that the
database is closed (and is not going to write anything to disk
anymore) before proceeding.

Thanks, Bruno



On Nov 11, 9:08 pm, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:
> Hi,
>
> > I got a database with one open connection. If I call close() will the
> > database be closed for good after the call returns?
>
> By default, yes, the database is closed when the last connection is
> closed. You can prevent that using the DB_CLOSE_DELAY, see alsohttp://www.h2database.com/html/grammar.html#setdbclosedelay
>
> > I need to be notified as soon as the database has definitely finished.
> > Should I be using the CloseListener?
>
> If you still need this feature, then you could use the
> DatabaseEventListener, seehttp://www.h2database.com/javadoc/org/h2/api/DatabaseEventListener.html
Reply all
Reply to author
Forward
0 new messages