apache > db
Apache DB Project
Font size:      

Starting the Network Server

Starting the Network Server

You can only run NetworkServerControl commands from the host that started the Network Server.

The Network Server itself resides in the $DERBY_INSTALL/lib.

For example, if you have installed Derby in the default directory on the C drive (in Windows) and you have set up your classpath correctly, type the following command:

java org.apache.derby.drda.NetworkServerControl start [-h <host>] [-p <portNumber>]

By default Network Server will only listen to requests on the loopback address so will only accept connections from the localhost.

You can alter that basic command to do any of the following:

  • Specify a port number other than the default(1527).

    Add -p <portnumber> after the start command:

    java org.apache.derby.drda.NetworkServerControl start -p 1368
  • Specify a specific interface (host name or IP address) to listen on other than the default (localhost).

    Add -h to the command:

    java org.apache.derby.drda.NetworkServerControl start -h myhost -p 1368

    This will enable connections from other hosts. You can specify a host name, ip address or to listen on all interfaces. You should run under the Java security manager and enable user authentication before using this option.

Starting the Network Server from a Java application

There are two ways of starting the network server from a Java application.

  • You can include the following line in the derby.properties file:
    This starts the server on the default port, 1527, listening on localhost (all interfaces). You may specify a different port or a specific interface in the derby.properties file. For example:
    You can also specify the startNetworkServer and portNumber properties using a Java command:
    java -Dderby.drda.startNetworkServer=true 
        -Dderby.drda.host=myhost yourApp
  • You can use the NetworkServerControl API to start the Network Server from a separate thread within a Java application:
    NetworkServerControl server = new NetworkServerControl(null);
    server.start (null);
    The NetworkServerControl.start method does not return until the server is shut down, so you should run it in its own thread.

Previous Page
Next Page
Table of Contents