You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Philippe Lamote <ph...@mac.com> on 2006/03/20 12:39:26 UTC
Derby Config Question
Hi List,
I'm new to Derby so if this is too trivial, don't mind rubbing my
nose into it ;-)
I have in my setup one place where I keep all the configuration
together. (jdoconfig.properties, Spring Configuration, ... )
Of course this would be the obvious place to also put the
"derby.properties". Yet this is not the place where I put the Derby
data files themselves.
So, in short, this would be the "package" layout:
- src/.../conf/derby.properties (will be copied to bin/.../conf @
compile time)
- data/... (the Derby data dir)
But then I read in the derby Manual: "You can set persistent system-
wide properties in a text file called derby.properties, which
must be placed in the directory specified by the derby.system.home
property."
I understand that "derby.system.home" would be this data directory
and this is not where I want to put the Derby properties.
I thought of this to solve it: in the general Application init
method, adding this:
Properties derbyProperties = new Properties();
try{
System.out.println("User dir property is "+ System.getProperty
("user.dir"));
String pathname = System.getProperty("user.dir") + "/src/.../conf/
derby.properties";
derbyProperties.load(new FileInputStream(new File(pathname)));
}
catch (IOException ioe) {
System.out.println("Couldn't load Derby properties." + ioe);
}
Properties systemprops = System.getProperties();
systemprops.putAll(derbyProperties); // adds the Derby Properties
to this JVM's System Properties.
--> Is this OK for Derby? And will the properties specified there
indeed be set & active upon the next connect? (and not make it put
all the dat files in my conf folder)
Thx,
Phil
Re: Derby Config Question
Posted by John Embretsen <Jo...@Sun.COM>.
Philippe Lamote wrote:
> Hi List,
>
> I'm new to Derby so if this is too trivial, don't mind rubbing my nose
> into it ;-)
>
> I have in my setup one place where I keep all the configuration
> together. (jdoconfig.properties, Spring Configuration, ... )
> Of course this would be the obvious place to also put the
> "derby.properties". Yet this is not the place where I put the Derby data
> files themselves.
>
> So, in short, this would be the "package" layout:
> - src/.../conf/derby.properties (will be copied to bin/.../conf @
> compile time)
> - data/... (the Derby data dir)
>
> But then I read in the derby Manual: "You can set persistent system-wide
> properties in a text file called /derby.properties/, which
> must be placed in the directory specified by the /derby.system.home/
> property."
>
> I understand that "derby.system.home" would be this data directory and
> this is not where I want to put the Derby properties.
> I thought of this to solve it: in the general Application init method,
> adding this:
<snip example of setting system properties programmatically>
> --> Is this OK for Derby? And will the properties specified there indeed
> be set & active upon the next connect? (and not make it put all the dat
> files in my conf folder)
Yes, I think this will work, as long as you connect to the database (or start
an embedded Derby server) from the same instance of the JVM.
I would, however, like to point out that properties specified
programmatically (which is your solution) have higher precedence than
properties that are automatically picked up by Derby from the
derby.properties file; see the Derby Tuning Guide,
http://db.apache.org/derby/docs/dev/tuning/. This may be a corner case, but:
Quoting http://db.apache.org/derby/docs/dev/tuning/ctunsetprop23308.html:
<quote>
This means, for example, that system-wide properties set programmatically
override database-wide properties and system-wide properties set in the
derby.properties file, and that database-wide properties override system-wide
properties set in the derby.properties file.
</quote>
So, if (for example) you previously relied on database-wide properties
overriding system-wide properties in the derby-properties file as it was
automatically picked up by Derby, you will find that this no longer happens,
since the properties are set programmatically instead, thus overriding the
database-wide properties.
Another possible work-around is to specify "full" database paths (absolute or
relative to derby.system.home), see
http://wiki.apache.org/db-derby/DatabaseNamesRelativeAbsolute.
--
John
Re: Derby Config Question
Posted by Rajesh Kartha <ka...@gmail.com>.
Hi Philippe,
I think this should work.
In your case the application is loading and setting all the Derby system
properties, whereas
following the Derby documentation way - pointing the derby.system.home
to the derby.properties, Derby would
have done it for you.
http://db.apache.org/derby/manuals/tuning/perf14.html#HDRSII-SETPROP-13074
-Rajesh
Philippe Lamote wrote:
> Hi List,
>
> I'm new to Derby so if this is too trivial, don't mind rubbing my nose
> into it ;-)
>
> I have in my setup one place where I keep all the configuration
> together. (jdoconfig.properties, Spring Configuration, ... )
> Of course this would be the obvious place to also put the
> "derby.properties". Yet this is not the place where I put the Derby
> data files themselves.
>
> So, in short, this would be the "package" layout:
> - src/.../conf/derby.properties (will be copied to bin/.../conf @
> compile time)
> - data/... (the Derby data dir)
>
> But then I read in the derby Manual: "You can set persistent
> system-wide properties in a text file called /derby.properties/, which
> must be placed in the directory specified by the /derby.system.home/
> property."
>
> I understand that "derby.system.home" would be this data directory and
> this is not where I want to put the Derby properties.
> I thought of this to solve it: in the general Application init method,
> adding this:
>
> Properties derbyProperties = new Properties();
>
> try{
> System.out.println("User dir property is "+
> System.getProperty("user.dir"));
> String pathname = System.getProperty("user.dir") +
> "/src/.../conf/derby.properties";
> derbyProperties.load(new FileInputStream(new File(pathname)));
> }
>
> catch (IOException ioe) {
> System.out.println("Couldn't load Derby properties." + ioe);
> }
> Properties systemprops = System.getProperties();
> systemprops.putAll(derbyProperties); // adds the Derby Properties to
> this JVM's System Properties.
>
>
> --> Is this OK for Derby? And will the properties specified there
> indeed be set & active upon the next connect? (and not make it put
> all the dat files in my conf folder)
>
> Thx,
> Phil
>
>
>
>