Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 80018 invoked from network); 3 Feb 2010 11:22:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Feb 2010 11:22:59 -0000 Received: (qmail 39478 invoked by uid 500); 3 Feb 2010 11:22:59 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 39413 invoked by uid 500); 3 Feb 2010 11:22:59 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 39402 invoked by uid 99); 3 Feb 2010 11:22:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 11:22:59 +0000 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul_t100@fastmail.fm designates 66.111.4.26 as permitted sender) Received: from [66.111.4.26] (HELO out2.smtp.messagingengine.com) (66.111.4.26) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 11:22:47 +0000 Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id E7E52DCE18; Wed, 3 Feb 2010 06:22:26 -0500 (EST) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Wed, 03 Feb 2010 06:22:26 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:date:from:reply-to:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; s=smtpout; bh=Gds3ytxekI0TYii6sF3wdQ9uwUg=; b=NVHV9pEMVqfmxz7TTRsiaUPcpWP0r8Qrw9vWNJcT8nKzjqHxJdUjy0o9Dv5TZxzf7w1g51VvO0cu1Nf/ZI9ImLuNDjnWeyxV8qh5lcIXOTmQaVmvphlC6aiFmyJioWBASvBl0wfvoDc3BAVVCVrxinA1YSyJAYO0x740AFG0Il8= X-Sasl-enc: TcYW1Q/LqSlsbme+rdGrvX2s2F18CsHwVRUtAVXeERU5 1265196146 Received: from [192.168.1.65] (unknown [217.155.98.246]) by mail.messagingengine.com (Postfix) with ESMTPA id 24EFE1F1BC; Wed, 3 Feb 2010 06:22:26 -0500 (EST) Message-ID: <4B695C71.2030403@fastmail.fm> Date: Wed, 03 Feb 2010 11:22:25 +0000 From: Paul Taylor Reply-To: paul_t100@fastmail.fm User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: "Dag H. Wanvik" CC: Derby Discussion Subject: Re: Best way to detect if embedded derby is being used by another application ? References: <4B680AD8.70909@fastmail.fm> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dag H. Wanvik wrote: > Paul Taylor 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 > > I thought if there was an abnormal termination then the db.lck is left in place and an attempt to boot the db will fail., and this wast he crux of my problem , my code is 99% Java but there is 1% native code provided by a 3rd party that I have to call using Runtime that does crash occasionally. But I've just tried starting my application , making copies of db.lck and db.ex.lck and the starting the program again and it actually starts okay. But in the real world I get users complaining that they cannot start the program because it complains the program is already running, even though it isnt, any ideas. Paul