db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dag.Wan...@Sun.COM (Dag H. Wanvik)
Subject Re: Best way to detect if embedded derby is being used by another application ?
Date Tue, 02 Feb 2010 14:45:36 GMT
Paul Taylor <paul_t100@fastmail.fm> writes:

> Hi, I'm trying to prevent a program being run concurrently by trying
> to access the database but getting in a bit of a mess, what is the
> simplest/neated way of doing this.

Normally (al least newer Derby releases), if you try to connect
(implied boot) a Derby database which has already been booted by
another VM you would get an error message. You could also check for
the presence of the db.lck file in the database's directory before you
attempt to boot a database.

  /export/home/tmp/derby/sb/sb1/wombat:
  :
  -rw-r--r--   1 user group       38 feb.  2 15:30 db.lck   <------- 
  -rw-r--r--   1 user group        4 feb.  2 15:30 dbex.lck
  drwxr-xr-x   2 user group      512 feb.  2 15:30 log
  drwxr-xr-x   2 user group     1536 feb.  2 15:30 seg0
  -rw-r--r--   1 user group      860 feb.  2 15:30 service.properties
  drwxr-xr-x   2 user group      512 feb.  2 15:30 tmp

On a normal shutdown this file will be removed. An abnormal
termination would leave the lock file in place, though, so that needs
to be considered before you decide if that's a sufficient hint for
your needs, since you could then risk starving the waiting VM..

Dag

Mime
View raw message