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 Van Couvering <da...@vancouvering.com> on 2007/09/13 01:47:05 UTC

SYSCS_GET_DATABASE_PROPERTY not working?

Hi, guys.  I know that NetBeans sets derby.system.home to
~/.netbeans-derby, but when I do

VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.system.home');

I get 'NULL'.

So, I tried this on both Derby 10.3 and Derby 10.2:

$ java -Dderby.system.home=/tmp -jar derbyrun.jar server start &

VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.system.home');

and I still get 'NULL'.

Am I missing something, or is this a bug?

What is the best way to query a network server to find out where it is
putting database directories?

Thanks,

David

Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by Oystein Grovlen - Sun Norway <Oy...@Sun.COM>.
David Van Couvering wrote:
> OK, sounds good, I guess you could do that.  But I do believe that it
> would be Very Nice if Derby provided this feature for your - for
> instance, when you do 'java -jar derbyrun.jar server sysinfo' it would
> print out, among all the other things, the value of derby.system.home.
>  Right now it doesn't, even if you explicitly set it when you start
> the server.
> 

Sounds like a good idea.

Note also that when the JMX support is ready (DERBY-1387), you should be 
able to get property settings with JMX.

-- 
Øystein

Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by David Van Couvering <da...@vancouvering.com>.
Hey, I could even add this myself.  One forgets sometimes that this is
open source and that one is a committer :)

David

On 9/13/07, David Van Couvering <da...@vancouvering.com> wrote:
> OK, sounds good, I guess you could do that.  But I do believe that it
> would be Very Nice if Derby provided this feature for your - for
> instance, when you do 'java -jar derbyrun.jar server sysinfo' it would
> print out, among all the other things, the value of derby.system.home.
>  Right now it doesn't, even if you explicitly set it when you start
> the server.
>
> Better yet, it should say "default database directory" and print out
> wherever that is, whether it is derby.system.home or user.dir.
>
> I'll log a feature request.
>
> David
>
> On 9/13/07, Knut Anders Hatlen <Kn...@sun.com> wrote:
> > David Van Couvering <da...@vancouvering.com> writes:
> >
> > > On 9/12/07, Øystein Grøvlen <Oy...@sun.com> wrote:
> > >> David Van Couvering wrote:
> > >>  > OK, fair enough.  So, how *do* I find out what derby.system.home is
> > >> set to??
> > >>  >
> > >>
> > >> I would think it is the same way as with any Java System property
> > >> (Kathey implicity told you that):
> > >>
> > >>      System.getProperty("derby.system.home");
> > >
> > > Yes, I know that.  But if I'm running the network server, how am I
> > > supposed to find out what the network server thinks is
> > > derby.system.home?  Especially if I'm interacting with Derby from a
> > > tool like NetBeans.  It could very well be that the developer is using
> > > JRuby or even PHP with ODBC, and is not even a Java programmer.
> >
> > If your network server has the necessary permissions to read
> > derby.system.home and user.dir (in case derby.system.home is null), you
> > could do something like this:
> >
> > ij version 10.3
> > ij> connect 'jdbc:derby://localhost/mydb;create=true';
> > ij> create function getSystemProperty(name varchar(128)) returns varchar(128) language java external name 'java.lang.System.getProperty' parameter style java no sql;
> > 0 rows inserted/updated/deleted
> > ij> values getSystemProperty('derby.system.home');
> > 1
> > --------------------------------------------------------------------------------------------------------------------------------
> > NULL
> >
> > 1 row selected
> > ij> values getSystemProperty('user.dir');
> > 1
> > --------------------------------------------------------------------------------------------------------------------------------
> > /tmp
> >
> > 1 row selected
> >
> >
> > --
> > Knut Anders
> >
>

Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by David Van Couvering <da...@vancouvering.com>.
OK, sounds good, I guess you could do that.  But I do believe that it
would be Very Nice if Derby provided this feature for your - for
instance, when you do 'java -jar derbyrun.jar server sysinfo' it would
print out, among all the other things, the value of derby.system.home.
 Right now it doesn't, even if you explicitly set it when you start
the server.

Better yet, it should say "default database directory" and print out
wherever that is, whether it is derby.system.home or user.dir.

I'll log a feature request.

David

On 9/13/07, Knut Anders Hatlen <Kn...@sun.com> wrote:
> David Van Couvering <da...@vancouvering.com> writes:
>
> > On 9/12/07, Øystein Grøvlen <Oy...@sun.com> wrote:
> >> David Van Couvering wrote:
> >>  > OK, fair enough.  So, how *do* I find out what derby.system.home is
> >> set to??
> >>  >
> >>
> >> I would think it is the same way as with any Java System property
> >> (Kathey implicity told you that):
> >>
> >>      System.getProperty("derby.system.home");
> >
> > Yes, I know that.  But if I'm running the network server, how am I
> > supposed to find out what the network server thinks is
> > derby.system.home?  Especially if I'm interacting with Derby from a
> > tool like NetBeans.  It could very well be that the developer is using
> > JRuby or even PHP with ODBC, and is not even a Java programmer.
>
> If your network server has the necessary permissions to read
> derby.system.home and user.dir (in case derby.system.home is null), you
> could do something like this:
>
> ij version 10.3
> ij> connect 'jdbc:derby://localhost/mydb;create=true';
> ij> create function getSystemProperty(name varchar(128)) returns varchar(128) language java external name 'java.lang.System.getProperty' parameter style java no sql;
> 0 rows inserted/updated/deleted
> ij> values getSystemProperty('derby.system.home');
> 1
> --------------------------------------------------------------------------------------------------------------------------------
> NULL
>
> 1 row selected
> ij> values getSystemProperty('user.dir');
> 1
> --------------------------------------------------------------------------------------------------------------------------------
> /tmp
>
> 1 row selected
>
>
> --
> Knut Anders
>

Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
David Van Couvering <da...@vancouvering.com> writes:

> On 9/12/07, Øystein Grøvlen <Oy...@sun.com> wrote:
>> David Van Couvering wrote:
>>  > OK, fair enough.  So, how *do* I find out what derby.system.home is
>> set to??
>>  >
>>
>> I would think it is the same way as with any Java System property
>> (Kathey implicity told you that):
>>
>>      System.getProperty("derby.system.home");
>
> Yes, I know that.  But if I'm running the network server, how am I
> supposed to find out what the network server thinks is
> derby.system.home?  Especially if I'm interacting with Derby from a
> tool like NetBeans.  It could very well be that the developer is using
> JRuby or even PHP with ODBC, and is not even a Java programmer.

If your network server has the necessary permissions to read
derby.system.home and user.dir (in case derby.system.home is null), you
could do something like this:

ij version 10.3
ij> connect 'jdbc:derby://localhost/mydb;create=true';
ij> create function getSystemProperty(name varchar(128)) returns varchar(128) language java external name 'java.lang.System.getProperty' parameter style java no sql;
0 rows inserted/updated/deleted
ij> values getSystemProperty('derby.system.home');
1                                                                                                                               
--------------------------------------------------------------------------------------------------------------------------------
NULL                                                                                                                            

1 row selected
ij> values getSystemProperty('user.dir');
1                                                                                                                               
--------------------------------------------------------------------------------------------------------------------------------
/tmp                                                                                                                            

1 row selected


-- 
Knut Anders

Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by David Van Couvering <da...@vancouvering.com>.
On 9/12/07, Øystein Grøvlen <Oy...@sun.com> wrote:
> David Van Couvering wrote:
>  > OK, fair enough.  So, how *do* I find out what derby.system.home is
> set to??
>  >
>
> I would think it is the same way as with any Java System property
> (Kathey implicity told you that):
>
>      System.getProperty("derby.system.home");

Yes, I know that.  But if I'm running the network server, how am I
supposed to find out what the network server thinks is
derby.system.home?  Especially if I'm interacting with Derby from a
tool like NetBeans.  It could very well be that the developer is using
JRuby or even PHP with ODBC, and is not even a Java programmer.

>
> I have not tried it, but it is possible that if this property is not
> explicitly set, this will also return null since Derby default values
> are not normally registered as properties.  (There was a discussion
> about this a couple of months ago.)
>

In the test I ran, I explicitly set derby.system.home, and still got NULL back.

To be honest, this seems like a real issue.  If a user can't query the
Network Server to find out where it is storing database directories,
it could be a long and painful search to find this directory,
especially when using tools like NB or Glassfish (and I think Eclipse)
that starts the Network Server for you, or if you have it registered
as a service on your machine.

David

> --
> Øystein
>

Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by Stanley Bradbury <St...@gmail.com>.
Øystein Grøvlen wrote:
> ====  SNIP
>
> I have not tried it, but it is possible that if this property is not
> explicitly set, this will also return null since Derby default values
> are not normally registered as properties.  (There was a discussion
> about this a couple of months ago.)
>
> -- 
> Øystein
>
Øystein  is correct.  If not set explicitly the call will return NULL.


Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by Øystein Grøvlen <Oy...@Sun.COM>.
David Van Couvering wrote:
 > OK, fair enough.  So, how *do* I find out what derby.system.home is 
set to??
 >

I would think it is the same way as with any Java System property
(Kathey implicity told you that):

     System.getProperty("derby.system.home");

I have not tried it, but it is possible that if this property is not
explicitly set, this will also return null since Derby default values
are not normally registered as properties.  (There was a discussion
about this a couple of months ago.)

--
Øystein

Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by David Van Couvering <da...@vancouvering.com>.
OK, fair enough.  So, how *do* I find out what derby.system.home is set to??

David

On 9/12/07, Kathey Marsden <km...@sbcglobal.net> wrote:
> David Van Couvering wrote:
> > Hi, guys.  I know that NetBeans sets derby.system.home to
> > ~/.netbeans-derby, but when I do
> >
> > VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.system.home');
> >
> > I get 'NULL'.
> >
> > So, I tried this on both Derby 10.3 and Derby 10.2:
> >
> > $ java -Dderby.system.home=/tmp -jar derbyrun.jar server start &
> >
> > VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.system.home');
> >
> > and I still get 'NULL'.
> >
> > Am I missing something, or is this a bug?
> >
> derby.system.home is a system property, not a database property so I think
>
> VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.system.home');
>
> is behaving as expected
>
> I guess to get the setting you could write  a stored procedure that does
> System.getProperty("derby.system.home");
>
> but I am not sure that will work with the default policy.
>
> Kathey
>
>
>

Re: SYSCS_GET_DATABASE_PROPERTY not working?

Posted by Kathey Marsden <km...@sbcglobal.net>.
David Van Couvering wrote:
> Hi, guys.  I know that NetBeans sets derby.system.home to
> ~/.netbeans-derby, but when I do
>
> VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.system.home');
>
> I get 'NULL'.
>
> So, I tried this on both Derby 10.3 and Derby 10.2:
>
> $ java -Dderby.system.home=/tmp -jar derbyrun.jar server start &
>
> VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.system.home');
>
> and I still get 'NULL'.
>
> Am I missing something, or is this a bug?
>   
derby.system.home is a system property, not a database property so I think

VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.system.home');

is behaving as expected

I guess to get the setting you could write  a stored procedure that does
System.getProperty("derby.system.home");

but I am not sure that will work with the default policy.

Kathey