db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: How to start derby netserver within an application
Date Sun, 28 Aug 2005 10:46:52 GMT
Kostas Karadamoglou <karadamoglou_k@yahoo.gr> writes:

> Hello all,
> I am developing an applicaiton that uses Derby 10.1.1. Since now I start 
> the database indepedently from the main application. I use ant to invoke 
> the derby net server. Here is one of my targets:


> I am planning to embedd the startup of the database network server 
> within the application. I found some references of doing that in 10.1.1 
> manual. Here is a sample code:

Will your database be accessed by other applications/clients? If only
one application will be accessing it, it would be better to use the
embedded mode.

> NetworkServerControl server = new 
> NetworkServerControl(InetAddress.getByName("localhost"),1528);
>             server.start(new PrintWriter(System.out));
> The code works fine. but I have two major problems. I would like to 
> start the database in a different directory than the current working 
> directory. For instance in a subdirectory called "db".
> How can I specify this? Which is the best option?

You could either start your application with -Dderby.system.home=...

    java -Dderby.system.home=/var/derby/db MyApp

or you could set the property in your Java code like this:

    System.setProperty("derby.system.home", "/var/derby/db");

> The second problem is that I dont receive ouput messages at the System.out.
> Do you know if the start method is used correcly.

It looks OK to me. Maybe the network server doesn't print many
messages? The argument to start() only tells where the network server
messages should be written. The database log messages are still
written to derby.log.

Knut Anders

View raw message