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 Afkham Azeez <af...@gmail.com> on 2006/02/01 06:26:50 UTC

Specifying the Derby Database Location

Hi Folks,

I have my derby.properties file in $MY_PROJECT/conf directory. This is
the directory pointed to by the derby.system.home System property. But
no my database is getting created under $MY_PROJECT/conf e.g. as
$MY_PROJECT/conf/DATABASE.

I need my database to be created as $MY_PROJECT/DATABASE. Is there a
property I can specify in the derby.properties file which will specify
the physical location of the Database?
--
Thanks in Advance
Afkham Azeez

Re: Specifying the Derby Database Location

Posted by John Embretsen <Jo...@Sun.COM>.
Afkham Azeez wrote:

> Hi Folks, Thanks for all the replies, Let me simplify my question:
> 
> I need to have my database and derby.properties file under different 
> directories, and the derby.system.home points to the directory which 
> contains the derby.properties file. And I need to use the relative 
> path of the DB since, the Database URL is hardcoded in an XML
> file(I'm using an Object Relational Mapping). Is this achievable?

Unless I am misunderstanding something here: Yes, you can do that by
using a relative database url. The url must be relative to
${derby.system.home} (as long as you have this property set, which you
seem to have).

Here's another attempt to answer your original question, I hope it helps:

If I set the ${MY_PROJECT} environment variable to e.g.
/home/user/projects/myProj, and place the derby.properties file in the
directory ${MY_PROJECT}/conf, I start ij like this:

java -Dderby.system.home=${MY_PROJECT}/conf org.apache.derby.tools.ij

I then create a database as ${MY_PROJECT}/DATABASE by doing:

ij> connect 'jdbc:derby:../DATABASE;create=true';



--
John


> On 2/2/06, Daniel John Debrunner <dj...@apache.org> wrote:
> 
>> Manjula G Kutty wrote:
>> 
>> 
>>> Afkham Azeez wrote:
>>> 
>>> 
>>>> Hi Folks,
>>>> 
>>>> I have my derby.properties file in $MY_PROJECT/conf directory.
>>>> This is the directory pointed to by the derby.system.home
>>>> System property. But no my database is getting created under
>>>> $MY_PROJECT/conf e.g. as $MY_PROJECT/conf/DATABASE.
>>>> 
>>>> I need my database to be created as $MY_PROJECT/DATABASE. Is
>>>> there a property I can specify in the derby.properties file
>>>> which will specify the physical location of the Database?
>> 
>> This is a good candidate for a Derby FAQ.
>> 
>> Database names in Derby are more than a single word, they are URL
>> like in that they can include the URL path separator character
>> forward slash '/'.
>> 
>> A database name is either relative or absolute.
>> 
>> An absolute path corresponds to an absolute path on your file
>> system:
>> 
>> jdbc:derby:/home/fred/databases/projects/cdcollection
>> 
>> top level folder for the database is 
>> /home/fred/databases/projects/cdcollection
>> 
>> 
>> jdbc:derby:d:/home/2006/accounts
>> 
>> top level folder for the database is d:\home\2006\accounts
>> 
>> A relative path is relative to the value of the system property 
>> derby.system.home if it is set, otherwise relative the current
>> working directory of the java virtual machine.
>> 
>> All these examples are different ways to connect to the
>> cdcollection database described above, examples on windows would be
>> similar, including use of the forward slash.
>> 
>> derby.system.home=/home/fred/databases 
>> jdbc:derby:projects/cdcollection
>> 
>> derby.system.home=/home/fred/databases/projects 
>> jdbc:derby:cdcollection
>> 
>> current working directory = /home/fred 
>> jdbc:derby:databases/projects/cdcollection
>> 
>> current working directory = /home/fred/databases/projects 
>> jdbc:derby:cdcollection


Re: Specifying the Derby Database Location

Posted by Afkham Azeez <af...@gmail.com>.
Hi Folks,
Thanks for all the replies, Let me simplify my question:

I need to have my database and derby.properties file under different
directories, and the derby.system.home points to the directory which
contains the derby.properties file. And I need to use the relative
path of the DB since, the Database URL is hardcoded in an XML file(I'm
using an Object Relational Mapping). Is this achievable?

Thanks in Advance
Azeez

On 2/2/06, Daniel John Debrunner <dj...@apache.org> wrote:
> Manjula G Kutty wrote:
>
> > Afkham Azeez wrote:
> >
> >> Hi Folks,
> >>
> >> I have my derby.properties file in $MY_PROJECT/conf directory. This is
> >> the directory pointed to by the derby.system.home System property. But
> >> no my database is getting created under $MY_PROJECT/conf e.g. as
> >> $MY_PROJECT/conf/DATABASE.
> >>
> >> I need my database to be created as $MY_PROJECT/DATABASE. Is there a
> >> property I can specify in the derby.properties file which will specify
> >> the physical location of the Database?
>
> This is a good candidate for a Derby FAQ.
>
> Database names in Derby are more than a single word, they are URL like
> in that they can include the URL path separator character forward slash '/'.
>
> A database name is either relative or absolute.
>
> An absolute path corresponds to an absolute path on your file system:
>
>   jdbc:derby:/home/fred/databases/projects/cdcollection
>
>    top level folder for the database is
>     /home/fred/databases/projects/cdcollection
>
>
>   jdbc:derby:d:/home/2006/accounts
>
>   top level folder for the database is
>      d:\home\2006\accounts
>
> A relative path is relative to the value of the system property
> derby.system.home if it is set, otherwise relative the current working
> directory of the java virtual machine.
>
> All these examples are different ways to connect to the cdcollection
> database described above, examples on windows would be similar,
> including use of the forward slash.
>
>   derby.system.home=/home/fred/databases
>   jdbc:derby:projects/cdcollection
>
>   derby.system.home=/home/fred/databases/projects
>   jdbc:derby:cdcollection
>
>   current working directory = /home/fred
>   jdbc:derby:databases/projects/cdcollection
>
>   current working directory = /home/fred/databases/projects
>   jdbc:derby:cdcollection
>
> HTH,
> Dan.
>
>
>


--
Thanks
Afkham Azeez

Re: Specifying the Derby Database Location

Posted by Susan Cline <ho...@pacbell.net>.
--- Daniel John Debrunner <dj...@apache.org> wrote:

> > Afkham Azeez wrote:
> > 
> >> Hi Folks,
> >>
> >> I have my derby.properties file in $MY_PROJECT/conf directory. This is
> >> the directory pointed to by the derby.system.home System property. But
> >> no my database is getting created under $MY_PROJECT/conf e.g. as
> >> $MY_PROJECT/conf/DATABASE.
> >>
> >> I need my database to be created as $MY_PROJECT/DATABASE. Is there a
> >> property I can specify in the derby.properties file which will specify
> >> the physical location of the Database?
> 
> This is a good candidate for a Derby FAQ.
> 
> Database names in Derby are more than a single word, they are URL like
> in that they can include the URL path separator character forward slash '/'.
> 

I created a wiki entry today with the information you posted about relative and absolute paths in
a JDBC connection URL:

http://wiki.apache.org/db-derby/DatabaseNamesRelativeAbsolute

Susan

Re: Specifying the Derby Database Location

Posted by Daniel John Debrunner <dj...@apache.org>.
Manjula G Kutty wrote:

> Afkham Azeez wrote:
> 
>> Hi Folks,
>>
>> I have my derby.properties file in $MY_PROJECT/conf directory. This is
>> the directory pointed to by the derby.system.home System property. But
>> no my database is getting created under $MY_PROJECT/conf e.g. as
>> $MY_PROJECT/conf/DATABASE.
>>
>> I need my database to be created as $MY_PROJECT/DATABASE. Is there a
>> property I can specify in the derby.properties file which will specify
>> the physical location of the Database?

This is a good candidate for a Derby FAQ.

Database names in Derby are more than a single word, they are URL like
in that they can include the URL path separator character forward slash '/'.

A database name is either relative or absolute.

An absolute path corresponds to an absolute path on your file system:

  jdbc:derby:/home/fred/databases/projects/cdcollection

   top level folder for the database is
    /home/fred/databases/projects/cdcollection


  jdbc:derby:d:/home/2006/accounts

  top level folder for the database is
     d:\home\2006\accounts

A relative path is relative to the value of the system property
derby.system.home if it is set, otherwise relative the current working
directory of the java virtual machine.

All these examples are different ways to connect to the cdcollection
database described above, examples on windows would be similar,
including use of the forward slash.

  derby.system.home=/home/fred/databases
  jdbc:derby:projects/cdcollection

  derby.system.home=/home/fred/databases/projects
  jdbc:derby:cdcollection

  current working directory = /home/fred
  jdbc:derby:databases/projects/cdcollection

  current working directory = /home/fred/databases/projects
  jdbc:derby:cdcollection

HTH,
Dan.



Re: Specifying the Derby Database Location

Posted by Manjula Kutty <ma...@gmail.com>.
Correction : You can not set the derby.system.home in the derby.properties
file.You should always explicitly set the value of *derby.system.home*


Thanks
Manjula

On 2/1/06, Manjula G Kutty <ma...@gmail.com> wrote:
>
> Afkham Azeez wrote:
>
> >Hi Folks,
> >
> >I have my derby.properties file in $MY_PROJECT/conf directory. This is
> >the directory pointed to by the derby.system.home System property. But
> >no my database is getting created under $MY_PROJECT/conf e.g. as
> >$MY_PROJECT/conf/DATABASE.
> >
> >I need my database to be created as $MY_PROJECT/DATABASE. Is there a
> >property I can specify in the derby.properties file which will specify
> >the physical location of the Database?
> >--
> >Thanks in Advance
> >Afkham Azeez
> >
> >
> >
> Hi,
>
> If you specify derby.system.home in your derby.properties file, then
> your database "will be" created in the directory specified by the
> derby.system.home. One way to create the database in another directory
> other than the derby.system.home is to specify the location in the
> jdbcurl. Like
> ij> connect 'jdbc:derby:<yourlocation/dbname>;create=true'.
>
> You can refer the derby tuning guide for further reference for
> derby.system.home property
> http://db.apache.org/derby/docs/10.1/tuning/rtunproper32066.html
>
> Thanks,
> Manjula
>

Re: Specifying the Derby Database Location

Posted by Manjula G Kutty <ma...@gmail.com>.
Afkham Azeez wrote:

>Hi Folks,
>
>I have my derby.properties file in $MY_PROJECT/conf directory. This is
>the directory pointed to by the derby.system.home System property. But
>no my database is getting created under $MY_PROJECT/conf e.g. as
>$MY_PROJECT/conf/DATABASE.
>
>I need my database to be created as $MY_PROJECT/DATABASE. Is there a
>property I can specify in the derby.properties file which will specify
>the physical location of the Database?
>--
>Thanks in Advance
>Afkham Azeez
>
>  
>
Hi,

If you specify derby.system.home in your derby.properties file, then 
your database "will be" created in the directory specified by the 
derby.system.home. One way to create the database in another directory 
other than the derby.system.home is to specify the location in the 
jdbcurl. Like
ij> connect 'jdbc:derby:<yourlocation/dbname>;create=true'.

You can refer the derby tuning guide for further reference for 
derby.system.home property
http://db.apache.org/derby/docs/10.1/tuning/rtunproper32066.html

Thanks,
Manjula