db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Noll <dan...@nuix.com.au>
Subject Re: Is it possible to force read-only mode?
Date Mon, 20 Jun 2005 23:45:09 GMT
Suresh Thalamati wrote:

> I tried the following steps to create a simple readonly DB on file 
> system it seems to  work fine for  me.
> 1)  shutdown the DB with no pending transaction (this step is same for 
> jars also), to avoid rollbacks during recovery on a readonly  system.
> 2) disable(deny)  write permission  for  all the files/directories   
> under databases directory for the user id. that  is starting  the 
> DB.    3) derby  store seems to recognize that  database is read only 
> if is it unable to create/modify files under database directory.
> 4)  start  each JVM that access the database with  property 
> derby.storage.tempDirectory 
> (D"derby.storage.tempDirectory=c:/temp/x2") to  specify  different
>      temp directory for each instance ,  for the queries to  create 
> temporary files in different directories.
> My guess  is , you are not disabling the write permissions correctly 
> for the database directory  on  the  OS. Otherwise it would not be 
> able to
> boot in the in the write mode at all,  because it needs to crearte 
> lock files,  and  log files ..etc to do anything.
You're right.

My problem here is, as my own user, I'm setting the directory to 
read-only, but under Windows that doesn't stop apps from writing to the 
directory (whereas under Linux, for example, it would... unless that app 
went and set the directory writeable somehow again.)  But... 
unfortunately, we want to support this scenario where one user creates 
some data, then sets their own data into read-only so that others can 
look at it.  So I'll have to come up with some other workaround.

I think my workaround might need to be some kind of classloader trick.

If I load the database from the classpath, even if the actual data is on 
the filesystem, Derby should still open in read-only mode.  The trick is 
going to be making a custom ClassLoader pointing to the parent directory 
of the database, and then somehow getting Derby to use that classpath 
instead of its normal one.  I guess if I load Derby from that same 
ClassLoader, then it should work.  Maybe there is another way though.

I guess another really horrible way to do it would be to add every 
filesystem root to the classpath.  It would be a bit heavy-handed, but I 
guess it would work as a last resort. :-)


Daniel Noll

NUIX Pty Ltd
Level 8, 143 York Street, Sydney 2000
Phone: (02) 9283 9010
Fax:   (02) 9283 9020

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

View raw message