background image
<< Setting port numbers | derby.drda.keepAlive property >>

Using the NetworkServerControl API

<< Setting port numbers | derby.drda.keepAlive property >>
Derby Server and Administration Guide
34
using the servlet interface
for information about starting and shutting down the Network
Server using the servlet interface.
Overview
You start the Derby Network Server using the command line or using the Derby Server
API. (Derby provides scripts for you to use to start the server from the command line.)
Before starting the server, you will probably set certain Derby and Network Server
properties.
Using the NetworkServerControl API
You need to create an instance of the NetworkServerControl class if you are using the
API. There are four constructors for this class:
Note: Before enabling connections from other systems, ensure that you are running
under a security manager.
· NetworkServerControl()
This constructor creates an instance that listens either on the default port
(1527) or the port that is set by the
derby.drda.portNumber
property.
It will also listen on the host set by the
derby.drda.host
property
or the loopback address if the property is not set. This is the default
constructor; it does not allow remote connections. It is equivalent to calling
NetworkServerControl(InetAddress.getByName("localhost"),1527) if no properties
are set.
· NetworkServerControl(InetAddress address, int portNumber)
This constructor creates an instance that listens on the specified
portNumber
on
the specified address. The
InetAddress
will be passed to
ServerSocket
. NULL
is an invalid address value. The following examples show how you might allow
Network Server to accept connections from other hosts:
//accepts connections from other hosts on an IPv4 system
NetworkServerControl serverControl =
new NetworkServerControl(InetAddress.getByName("0.0.0.0"),1527);
//accepts connections from other hosts on an IPv6 system
NetworkServerControl serverControl =
new NetworkServerControl(InetAddress.getByName("::"),1527);
· NetworkServerControl(String userName, String password)
If a network server should run with user authentication, certain operations like
NetworkServerControl.shutdown() require that you provide user credentials. This
constructor creates an instance with user credentials, which are then used for
operations that require them. In all other aspects, this constructor behaves like
NetworkServerControl().
· NetworkServerControl(InetAddress address, int portNumber, String userName,
String password)
This constructor creates an instance with user credentials, which are then used
for operations that require them. In all other aspects, this constructor behaves like
NetworkServerControl(InetAddress address, int portNumber).
Setting Network Server properties
You can specify Network Server properties in three ways:
· On the command line
· In the
.bat
or
.ksh
files (loading the properties by executing
java -D
)
· In the
derby.properties
file.