db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: Delete Database that is locked by the network server
Date Mon, 11 Jan 2010 13:37:22 GMT
Damian Hofmann <damian.hofmann@gmx.ch> writes:

> Hi
> My application must delete a derby database under certain
> contidions. The scenario is, that a limited group of users edit and
> review data in a "work-database" and from time to time, release their
> work to the public. The release is done by creating a copy of the
> "work-database" and redirect all new requests to the new
> "public-database". The old "public-database" stays in place to serve
> requests, that have not been finished at the time of the release. This
> works well so far.
> But after these old requests have been served, I want to delete the
> old "public-database". As I understand from other posts to this
> mailing list, deleting a derby database means, deleting the
> database-directory from the filesystem. But I face two problems with
> that:
> 1. How can I determine that no connections/sessions to the old
> "public-database" are open?

You can use the runtimeinfo command [1] to see how many open connections
there are on a server. This only helps you if you have one network
server process per database, though, since runtimeinfo doesn't give you
number of connections per database.

> 2. How can I tell the derby network server to "release" the old
> "public-database", so I don't run into a "file is by an other person
> or program" error? The networkserver seems to hold some file-locks, so
> i can't just delete the directory. I don't want to shut down the whole
> network server, since it is serving the other databases.

It is possible to shut down a single database on the server. Just open a
connection with the database name specified and shutdown=true:


The above code should make the server release all file locks in
"old-database", so it should be safe to remove the directory. The
developer's guide [2] contains more details about shutting down

[1] http://db.apache.org/derby/docs/10.5/adminguide/tadminappsruntimeinfo.html
[2] http://db.apache.org/derby/docs/10.5/devguide/tdevdvlp40464.html

Knut Anders

View raw message