public class NetworkServerControl extends Object
Properties can be set in the derby.properties file or on the command line. Properties on the command line take precedence over properties in the derby.properties file. Arguments on the command line take precedence over properties. The following is a list of properties that can be set for NetworkServerControl:
Examples.
This is an example of shutting down the server on port 1621.
java org.apache.derby.drda.NetworkServerControl shutdown -p 1621
This is an example of turning tracing on for session 3
java org.apache.derby.drda.NetworkServerControl trace on -s 3
This is an example of starting and then shutting down the Network Server on port 1621 on machine myhost
java org.apache.derby.drda.NetworkServerControl start -h myhost -p 1621 java org.apache.derby.drda.NetworkServerControl shutdown -h myhost -p 1621
This is an example of starting and shutting down the Network Server in the example above with the API.
NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName("myhost"),1621) serverControl.shutdown();
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PORTNUMBER |
Constructor and Description |
---|
NetworkServerControl()
Creates a NetworkServerControl object that is configured to control
a Network Server on the default host(localhost)
and the default port(1527) unless derby.drda.portNumber and
derby.drda.host are set.
|
NetworkServerControl(InetAddress address,
int portNumber)
Creates a NetworkServerControl object that is configured to control
a Network Server on a specified port and InetAddress.
|
NetworkServerControl(InetAddress address,
int portNumber,
String userName,
String password)
Creates a NetworkServerControl object that is configured to control
a Network Server on a specified port and InetAddress with given
user credentials.
|
NetworkServerControl(String userName,
String password)
Creates a NetworkServerControl object that is configured to control
a Network Server on the default host and the default port with given
user credentials.
|
Modifier and Type | Method and Description |
---|---|
Properties |
getCurrentProperties()
Get current Network server properties
|
int |
getMaxThreads()
Returns the current maxThreads setting for the running Network Server
|
String |
getRuntimeInfo()
Return detailed session runtime information about sessions,
prepared statements, and memory usage for the running Network Server.
|
String |
getSysinfo()
Return classpath and version information about the running
Network Server.
|
int |
getTimeSlice()
Return the current timeSlice setting for the running Network Server
|
void |
logConnections(boolean on)
Turn logging connections on or off.
|
static void |
main(String[] args)
main routine for NetworkServerControl
|
void |
ping()
Check if the Network Server is started.
|
void |
setMaxThreads(int max)
Set Network Server maxthread parameter.
|
void |
setTimeSlice(int timeslice)
Set Network Server connection time slice parameter.
|
void |
setTraceDirectory(String traceDirectory)
Set directory for trace files.
|
void |
shutdown()
Shutdown a Network Server.
|
void |
start(PrintWriter consoleWriter)
Start a Network Server.
|
void |
trace(boolean on)
Turn tracing on or off for the specified connection
on the Network Server.
|
void |
trace(int connNum,
boolean on)
Turn tracing on or off for all connections on the Network Server.
|
public static final int DEFAULT_PORTNUMBER
public NetworkServerControl(InetAddress address, int portNumber, String userName, String password) throws Exception
address
- The IP address of the Network Server host.
address cannot be null.portNumber
- port number server is to used. If <= 0,
default port number is useduserName
- The user name for actions requiring authorization.password
- The password for actions requiring authorization.Exception
- on errorpublic NetworkServerControl(String userName, String password) throws Exception
userName
- The user name for actions requiring authorization.password
- The password for actions requiring authorization.Exception
- on errorpublic NetworkServerControl(InetAddress address, int portNumber) throws Exception
Examples:
To configure for port 1621 and listen on the loopback address:
NetworkServerControl util = new NetworkServerControl(InetAddress.getByName("localhost"), 1621);
address
- The IP address of the Network Server host.
address cannot be null.portNumber
- port number server is to used. If <= 0,
default port number is usedException
- on errorpublic NetworkServerControl() throws Exception
new NetworkServerControl() is equivalent to calling new NetworkServerControl(InetAddress.getByName("localhost"),1527);
Exception
- on errorpublic static void main(String[] args)
args
- array of arguments indicating command to be executed.
See class comments for more informationpublic void start(PrintWriter consoleWriter) throws Exception
Note: an alternate method to starting the Network Server with the API, is to use the derby.drda.startNetworkServer property in derby.properties.
consoleWriter
- PrintWriter to which server console will be
output. Null will disable console output.Exception
- if there is an error starting the server.shutdown()
public void shutdown() throws Exception
Exception
- throws an exception if an error occurspublic void ping() throws Exception
Exception
- throws an exception if an error occurspublic void trace(boolean on) throws Exception
on
- true to turn tracing on, false to turn tracing off.Exception
- throws an exception if an error occurspublic void trace(int connNum, boolean on) throws Exception
connNum
- connection number. Note: Connection numbers will print
in the Derby error log if logConnections is onon
- true to turn tracing on, false to turn tracing off.Exception
- throws an exception if an error occurspublic void logConnections(boolean on) throws Exception
on
- true to turn on, false to turn offException
- throws an exception if an error occurspublic void setTraceDirectory(String traceDirectory) throws Exception
traceDirectory
- directory for trace files on machine
where server is runningException
- throws an exception if an error occurspublic String getSysinfo() throws Exception
Exception
- throws an exception if an error occurspublic String getRuntimeInfo() throws Exception
Exception
- throws an exception if an error occurspublic void setMaxThreads(int max) throws Exception
max
- maximum number of connection threads.
If <= 0, connection threads will be created when
there are no free connection threads.Exception
- throws an exception if an error occurssetTimeSlice(int)
public int getMaxThreads() throws Exception
Exception
- throws an exception if an error occurssetMaxThreads(int)
public void setTimeSlice(int timeslice) throws Exception
timeslice
- number of milliseconds given to each session before yielding to
another session, if <=0, never yield.Exception
- throws an exception if an error occurssetMaxThreads(int)
public int getTimeSlice() throws Exception
Exception
- throws an exception if an error occurssetTimeSlice(int)
public Properties getCurrentProperties() throws Exception
Exception
- throws an exception if an error occursApache Derby 10.13 API Documentation - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.