db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Embretsen <John.Embret...@Sun.COM>
Subject Re: running Mode config
Date Thu, 23 Mar 2006 17:29:23 GMT
Hi Philippe,

I think you describe an interesting use case which confirms the fact
that the Derby documentation certainly could be better in a lot of
areas. I actually think I learned something :) while trying to figure out
the proper answers to your questions; see below...

Wednesday, March 22, 2006, 12:37:02 PM CET, Philippe Lamote wrote:

<snip details>

> - I feel setting "derby.drda.startNetworkServer" to "true" AND
> issuing the "new NetworkServerControl(...)" are doing twice the same  
> and that I can (as in: would better!) drop one of them. Is this correct?

Yes, you can drop one or the other, and it will still work.

By the way, a note from looking at your code snippet:
It is recommended that you set system properties by using the
System.setProperty(...) method instead of the put(...) method you are
using (see e.g. javadoc for java.util.Properties). So, instead of

System.getProperties().put("derby.drda.startNetworkServer","true");

you should use

System.setProperty("derby.drda.startNetworkServer", "true");

> - Is the driver the app itself has to use to connect to the DB, after  
> firing the Network Server: the ClientDriver, or the EmbeddedDriver?  
> The doc got me confused about this.

AFTER starting the Network Server, the app which started the server can
use either driver for accessing the database. Other apps (running in
other JVMs) MUST use the client driver to connect to the DB.

See also the Derby tutorial at
http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Embedded+Server

What I did _not_ find clearly stated in the docs or the tutorial,
however, is how you should start derby when using the property
derby.drda.startNetworkServer=true. The admin guide says

"When you set derby.drda.startNetworkServer, the Network Server will
automatically start when you start Derby."

Now, what probably should have been included in the manual and the
tutorial, is that you start Derby in this case by loading the embedded
driver:

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

And voila, you have a running "embedded server".

You can then create connections using both the embedded driver _and_ the
client driver in that same application.

You can also, after starting the server as shown above, access the
Network Server from _other_ JVMs (external clients) by using the client
driver, as long as the JVM which started the server is still running.

> - Any suggestions as to how to make this work properly? :-) It looks  
> like either the Server has shutdown already when I use the DB app  
> (although the server was started and not shutdown that I know of), or  
> that I need a password (thought this was never necessary, unless you  
> explicitely set "authentication" somewhere)

I am not sure from where you are trying to access the derby server (same
JVM? Another JVM?). But the bottom line is that the server shuts down
when you explicitly tell it to do so, or when the JVM which launched the
server exits, whichever comes first.

No username/password necessary by default.

Hope this helps!


-- 
John


Mime
View raw message