This actually did work, oddly enough.  I wonder how Derby is undoing the 
read-only attribute on those directories?  But in any case, I'm revamping the 
core setup/shutdown code again so that there's a decent hook in place to do the 
derby shutdown.

Karl


-----Original Message-----
From: ext Mark Miller [mailto:markrmil...@gmail.com] 
Sent: Wednesday, June 09, 2010 4:26 PM
To: connectors-dev@incubator.apache.org
Subject: Re: Derby/JUnit bad interaction - any ideas?

On 6/8/10 6:35 AM, karl.wri...@nokia.com wrote:
> I've been trying to get some basic tests working under Junit.  Unfortunately, 
> I've run into a Derby problem which prevents these tests from working.
>
> What happens is this.  Derby, when it creates a database, forces a number of 
> directories within the database to "read-only".  Unfortunately, unless we 
> stipulate Java 1.6 or up, there is no native Java way to make these 
> directories become non-read-only.  So database cleanup always fails to 
> actually remove the old database, and then new database creation subsequently 
> fails.
>
> So there are two possibilities.  First, we can change things so we never 
> actually try to clean up the Derby DB.  Second, we can mandate the java 1.6 
> is used for LCF.  That's all there really is.
>
> The first possibility is tricky but doable - I think.  The second would 
> probably be unacceptable in many ways.
>
> Thoughts?
>
> Karl
>
>
>
>

So I've been thinking about this - I still have trouble believing this 
is a real problem. I had a large suite of tests that used embedded derby 
in a system I worked on a few years back - and I never had any trouble 
removing the db dir after shutting down derby.

Looking at the code, have you actually tried shutting down derby?

Currently you have:

     // Cause database to shut down
     new 
Database(context,_url+databaseName+";shutdown=true",_driver,databaseName,"","");
     // DO NOT delete user or shutdown database, since this is in fact 
impossible under java 1.5 (since Derby makes its directories read-only, and
     // there's no way to undo that...
     // rm -rf <databasename>
     //File f = new File(databaseName);
     //recursiveDelete(f);

But that is not going to do the shutdown?
On a quick look, doing new Database(context, url ...
does not actually contact the db - so its not going to cause it to shutdown?

Is this just cruft code and you have actually tried shutting down as well?

Something makes me think the delete is going to work if you actually 
attempt to connect with '...;shutdown=true' jdbc URL.

-- 
- Mark

http://www.lucidimagination.com

Reply via email to