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 David Harrigan <da...@orange-ft.com> on 2006/09/21 11:24:13 UTC

derby.system.home not being honoured!

Hi,

Thanks to all that helped out in my other question,
re: gui tools.

I have another, more serious problem.

I'm trying to access a database from within a unit
test from within eclipse.

I'm invoking my class under test and in that class
I have:

System.setProperty("derby.system.home", getDerbySystemHome());
connection = DriverManager.getConnection("jdbc:derby:searchdb",
System.getProperties());

The getDerbySystemHome() returns a directory that is inside 
the project directory within eclipse, (projectname/web/WEB-INF/classes/)
yet I continuously get this error when I try to execute the test:

EmbedSQLException : Database 'searchdb' not found.

If I change the connection string to:

jdbc:derby:searchdb;create=true

It creates the database, but at the ROOT of the eclipse project! i.e.,

(projectname/searchdb)

My question is this, why is Derby not honouring the derby.system.home
that I am explicitly setting in the System properties and then
subsequently
passing into the DriverManager...

-=david=-


This email and the files transmitted with it are meant solely for the use of the individual addressee(s) named above. They may contain confidential and/or legally privileged information. If you are not the addressee(s) or responsible for delivery of the message to the addressee(s), please delete it from your system and contact the sender right away. The opinions, conclusions and other information in this message which do not relate to the official business of Orange Home UK plc are not necessarily endorsed by it. Orange Home UK plc has taken steps to ensure that this email and any attachments are virus-free, but it remains your responsibility to confirm and ensure this.

Orange Home UK plc is a subsidiary of France Telecom SA. Our registered office is at: Verulam Point, Station Way, St. Albans, Herts, AL1 5HE, and we are registered in England and Wales, as Company No. 3014367

RE: derby.system.home not being honoured!

Posted by David Harrigan <da...@orange-ft.com>.
Hi John,

Fantastic! That was the issue. I moved the call to
getDerbySystemHome() to my static initaliser block (yes,
you are correct in assuming it's an embedded instance) and
now it finds the database. Thank you indeed for your
prompt reply.

-=david=- 

-----Original Message-----
From: John.Embretsen@Sun.COM [mailto:John.Embretsen@Sun.COM] 
Sent: 21 September 2006 10:35
To: Derby Discussion
Subject: Re: derby.system.home not being honoured!

David Harrigan wrote:
[...]

> I'm invoking my class under test and in that class I have:
> 
> System.setProperty("derby.system.home", getDerbySystemHome()); 
> connection = DriverManager.getConnection("jdbc:derby:searchdb",
> System.getProperties());
> 
> The getDerbySystemHome() returns a directory that is inside the 
> project directory within eclipse, (projectname/web/WEB-INF/classes/)
> yet I continuously get this error when I try to execute the test:
> 
> EmbedSQLException : Database 'searchdb' not found.
> 
> If I change the connection string to:
> 
> jdbc:derby:searchdb;create=true
> 
> It creates the database, but at the ROOT of the eclipse project! i.e.,
> 
> (projectname/searchdb)
> 
> My question is this, why is Derby not honouring the derby.system.home 
> that I am explicitly setting in the System properties and then 
> subsequently passing into the DriverManager...

derby.system.home is a static property that must be set before Derby
starts, i.e. before the driver is loaded (I assume you are using the
embedded driver). When you call getConnection(...), Derby has already
started, so the new property value will have no effect. Does setting the
property before loading the driver (Class.forName(...)) resolve your
issue?


--
John


This email and the files transmitted with it are meant solely for the use of the individual addressee(s) named above. They may contain confidential and/or legally privileged information. If you are not the addressee(s) or responsible for delivery of the message to the addressee(s), please delete it from your system and contact the sender right away. The opinions, conclusions and other information in this message which do not relate to the official business of Orange Home UK plc are not necessarily endorsed by it. Orange Home UK plc has taken steps to ensure that this email and any attachments are virus-free, but it remains your responsibility to confirm and ensure this.

Orange Home UK plc is a subsidiary of France Telecom SA. Our registered office is at: Verulam Point, Station Way, St. Albans, Herts, AL1 5HE, and we are registered in England and Wales, as Company No. 3014367

Re: derby.system.home not being honoured!

Posted by John Embretsen <Jo...@Sun.COM>.
David Harrigan wrote:
[...]

> I'm invoking my class under test and in that class
> I have:
> 
> System.setProperty("derby.system.home", getDerbySystemHome());
> connection = DriverManager.getConnection("jdbc:derby:searchdb",
> System.getProperties());
> 
> The getDerbySystemHome() returns a directory that is inside 
> the project directory within eclipse, (projectname/web/WEB-INF/classes/)
> yet I continuously get this error when I try to execute the test:
> 
> EmbedSQLException : Database 'searchdb' not found.
> 
> If I change the connection string to:
> 
> jdbc:derby:searchdb;create=true
> 
> It creates the database, but at the ROOT of the eclipse project! i.e.,
> 
> (projectname/searchdb)
> 
> My question is this, why is Derby not honouring the derby.system.home
> that I am explicitly setting in the System properties and then
> subsequently
> passing into the DriverManager...

derby.system.home is a static property that must be set before Derby 
starts, i.e. before the driver is loaded (I assume you are using the 
embedded driver). When you call getConnection(...), Derby has already 
started, so the new property value will have no effect. Does setting the 
property before loading the driver (Class.forName(...)) resolve your issue?


-- 
John