org.apache.derby.impl.drda
Class DB2jServerImpl

java.lang.Object
  extended byorg.apache.derby.impl.drda.DB2jServerImpl

public class DB2jServerImpl
extends java.lang.Object

DB2jServerImpl does all the work for DB2jServer

See Also:
for description

Field Summary
private  java.lang.Runnable acceptClients
           
private  java.util.Hashtable appRequesterTable
           
protected static java.lang.String att_extnam
           
protected static java.lang.String att_srvclsnm
           
protected static java.lang.String ATT_SRVNAM
           
protected static java.lang.String att_srvrlslv
           
private  java.lang.String bootPasswordArg
           
private static java.lang.String buildNumber
           
private  java.io.ByteArrayOutputStream byteArrayOs
           
protected static int CCSIDMBC
           
protected static int CCSIDSBC
           
private  boolean cleanupOnStart
           
private  java.io.InputStream clientIs
           
 java.lang.String clientLocale
           
private  java.io.OutputStream clientOs
           
private  java.net.Socket clientSocket
           
private static java.lang.String CLOUDSCAPE_DRIVER
           
protected  java.sql.Driver cloudscapeDriver
           
protected  java.io.PrintWriter cloudscapeLogWriter
           
private static int[] COMMAND_ARGS
           
private static java.lang.String COMMAND_HEADER
           
private static int COMMAND_LOGCONNECTIONS
           
private static int COMMAND_MAXTHREADS
           
private static int COMMAND_PROPERTIES
           
private static int COMMAND_RUNTIME_INFO
           
private static int COMMAND_SHUTDOWN
           
private static int COMMAND_START
           
private static int COMMAND_SYSINFO
           
private static int COMMAND_TESTCONNECTION
           
private static int COMMAND_TIMESLICE
           
private static int COMMAND_TRACE
           
private static int COMMAND_TRACEDIRECTORY
           
private static int COMMAND_UNKNOWN
           
private  java.util.Vector commandArgs
           
private  java.io.DataOutputStream commandOs
           
private static java.lang.String[] COMMANDS
           
private  int connNum
           
private  Session currentSession
           
private static int DASHARG_BOOTPASSWORD
           
private static int DASHARG_DATABASE
           
private static int DASHARG_ENCALG
           
private static int DASHARG_ENCPRV
           
private static int DASHARG_HOST
           
private static int DASHARG_LOADSYSIBM
           
private static int DASHARG_PORT
           
private static int DASHARG_SESSION
           
private static int DASHARG_USER
           
private static java.lang.String[] DASHARGS
           
private  java.lang.String databaseArg
           
private static java.lang.String DB2J_PROP_STREAM_ERROR_FIELD
           
private static java.lang.String DB2J_PROP_STREAM_ERROR_FILE
           
private static java.lang.String DB2J_PROP_STREAM_ERROR_METHOD
           
protected  boolean debugOutput
           
protected static int DEFAULT_CCSID
           
protected static java.lang.String DEFAULT_ENCODING
           
private static java.lang.String DEFAULT_HOST
           
private static java.lang.String DEFAULT_LOCALE
           
private static java.lang.String DEFAULT_LOCALE_COUNTRY
           
private static int DEFAULT_MAXTHREADS
           
protected static int DEFAULT_SECURITY_MECHANISM
           
private static int DEFAULT_TIMESLICE
           
private static java.lang.String DRDA_MSG_PREFIX
           
private static java.lang.String DRDA_PROP_DEBUG
           
private static java.lang.String DRDA_PROP_MESSAGES
           
private  java.lang.String encAlgArg
           
private  java.lang.String encPrvArg
           
private static int ERROR
           
private  java.lang.String errorLogLocation
           
private static int ERRTYPE_INFO
           
private static int ERRTYPE_SEVERE
           
private static int ERRTYPE_UNKNOWN
           
private static int ERRTYPE_USER
           
private  int freeThreads
           
private  java.net.InetAddress hostAddress
           
private  java.lang.String hostArg
           
private  boolean keepAlive
           
private  LocalizedResource langUtil
           
(package private)  java.util.ArrayList localAddresses
           
private  boolean logConnections
           
private  java.lang.Object logConnectionsSync
           
protected  java.io.PrintWriter logWriter
           
private  int maxPoolSize
           
private static int MAXREPLY
           
private  int maxThreads
           
private  memCheck mc
           
protected static int[] MGR_LEVELS
           
private static int MIN_MAXTHREADS
           
private static int MIN_TIMESLICE
           
private  int minPoolSize
           
private  int minThreads
           
private static int NO_USAGE_MSGS
           
private static int OK
           
private  java.lang.String passwordArg
           
private  java.lang.Object poolSync
           
private  int portNumber
           
protected static java.lang.String prdId
           
private  java.lang.String propertyFileName
           
private static int PROTOCOL_VERSION
           
private static java.lang.String REPLY_HEADER
           
private static int REPLY_HEADER_LENGTH
           
private  byte[] replyBuffer
           
private  int replyBufferCount
           
private  int replyBufferPos
           
private  boolean restartFlag
           
private  java.util.Vector runQueue
           
private  DB2jServerImpl serverInstance
           
private  java.net.ServerSocket serverSocket
           
private  java.lang.Object serverStartSync
           
private  int sessionArg
           
private  java.util.Hashtable sessionTable
           
private  boolean shutdown
           
private static int SHUTDOWN_CHECK_ATTEMPTS
           
private static int SHUTDOWN_CHECK_INTERVAL
           
private  java.lang.Object shutdownSync
           
protected static byte SPACE_CHAR
           
private static int SQLERROR
           
private static int SQLWARNING
           
private  java.util.Vector threadList
           
private  java.lang.Object threadsSync
           
private  int timeSlice
           
private  java.lang.Object timeSliceSync
           
private  boolean traceAll
           
private  java.lang.Object traceAllSync
           
private  java.lang.String traceDirectory
           
private  java.lang.Object traceDirectorySync
           
protected static java.lang.String UNEXPECTED_ERR
           
private static int USE_DEFAULT
           
private  java.lang.String userArg
           
private static int WARNING
           
 
Constructor Summary
DB2jServerImpl()
           
DB2jServerImpl(java.net.InetAddress address, int portNumber)
          Internal constructor for NetworkServerControl API.
 
Method Summary
protected  void addToSessionTable(java.lang.Integer i, Session s)
          Add To Session Table - for use by ClientThread, add a new Session to the sessionTable.
 void blockingStart(java.io.PrintWriter consoleWriter)
          Start a network server
private  void buildLocalAddressList(java.net.InetAddress bindAddr)
          Build local address list to allow admin commands.
 java.lang.String buildRuntimeInfo(LocalizedResource locallangUtil)
           
private  void checkAddressIsLocal(java.net.InetAddress inetAddr)
           
private  void clientSocketError(java.io.IOException e)
          Stream error writing to client socket
private  void connectToDatabase(DDMWriter writer, java.lang.String database, java.lang.String user, java.lang.String password)
          Connect to a database to test whether a connection can be made
 void consoleError(java.lang.String msg)
          Write an error message to console output stream and throw an exception for this error
 void consoleExceptionPrint(java.lang.Exception e)
          Write an exception to console output stream, but only if debugOutput is true.
 void consoleExceptionPrintTrace(java.lang.Throwable e)
          Write an exception (with trace) to console output stream.
 void consoleMessage(java.lang.String msg)
          Write a message to console output stream
protected  void consolePropertyMessage(java.lang.String msgProp)
          Put property message on console
protected  void consolePropertyMessage(java.lang.String msgProp, java.lang.String arg)
          Put property message on console
protected  void consolePropertyMessage(java.lang.String msgProp, java.lang.String[] args)
          Put property message on console
private  void consolePropertyMessageWork(java.lang.String messageKey, java.lang.String[] args)
          Handle console error message - display on console and if it is a user error, display usage - if user error or severe error, throw exception with message key and message
private  void consoleTraceMessage(int connNum, boolean on)
          Print trace change message to console
 void directShutdown()
           
private  void ensureDataInBuffer(int minimumBytesNeeded)
          Ensure the reply buffer is at large enought to hold all the data; don't just rely on OS level defaults
static void execute(java.lang.String[] args)
          Execute the command given on the command line
protected  void executeWork(java.lang.String[] args)
          Execute the command given on the command line
private  void fillReplyBuffer()
          Fill the reply buffer with the reply allocates a reply buffer if one doesn't exist
private  int findCommand(java.lang.String[] args)
          Go through the arguments and find the command and save the dash arguments and arguments to the command.
protected  AppRequester getAppRequester(AppRequester appRequester)
          Get the stored application requester or store if we haven't seen it yet
private  java.lang.String getCLSSysInfo()
          Get Cloudscape information
 java.util.Properties getCurrentProperties()
          Get current properties
 java.lang.String getErrorLogLocation()
           
protected  int getFreeThreads()
          Get Free Threads - for use by ClientThread, get the number of free threads in order to determine if a new thread can be run.
private  int getIntPropVal(java.lang.String propName, java.lang.String propVal)
          Get integer property values
protected  boolean getKeepAlive()
          Get the current value of keepAlive to configure how long the server should keep the socket alive for a disconnected client
 boolean getLogConnections()
          Get the current value of logging connections
protected  int getManagerLevel(int manager)
          Get the server manager level for a given manager
private  int getMaxPoolSize()
          Get the current value of maximum number of pooled connections to create
protected  int getMaxThreads()
          Get the current value of maximum number of threads to create
private  int getMessageType(java.lang.String msg)
          Determine type of message
private  int getMinPoolSize()
          Get the current value of minimum number of pooled connections to create at start
private  int getMinThreads()
          Get the current value of minimum number of threads to create at start
private  ProductVersionHolder getNetProductVersionHolder()
          Retrieve product version information We need to make sure that this method gets the stream and passes it to ProductVersionHolder, because it lives in the Network Server jar and won't be readily available to ProductVersionHolder when running under security manager.
private  java.lang.String getNetSysInfo()
          Get Net Server information
protected  int getNewConnNum()
          Get New Conn Num - for use by ClientThread, generate a new connection number for the attempted Session.
protected  Session getNextSession(Session currentSession)
          Get the next session for the thread to work on Called from DRDAConnThread after session completes or timeslice exceeded.
private  void getPropertyInfo()
          Get property info
private  java.util.Properties getPropertyValues()
           
private  java.lang.String getRuntimeInfo()
           
protected  boolean getShutdown()
           
protected  java.lang.Object getShutdownSync()
           
protected  java.util.Vector getThreadList()
          Get Thread List - for use by ClientThread, get the thread list Vector so that a newly spawned thread can be run and added to the ThreadList from the ClientThread
protected  int getTimeSlice()
          Get the current value of the time slice
protected  boolean getTraceAll()
          Get the current value of whether to trace all the sessions
protected  java.lang.String getTraceDirectory()
          Get the current value of trace directory
private  void init()
           
protected static boolean isCmd(java.lang.String val)
          Is this the command protocol
private  boolean isMsgProperty(java.lang.String msg)
          Determine whether string is a property key or not property keys start with DRDA_MSG_PREFIX
private  boolean isOn(java.lang.String arg)
          Is string "on" or "off"
 boolean isServerStarted()
           
private  java.lang.String localizeMessage(java.lang.String msgProp, LocalizedResource localLangUtil, java.lang.String[] args)
          Localize a message given a particular AppUI
 void logConnections(boolean on)
          Turn logging connections on or off.
private  java.io.PrintWriter makePrintWriter(java.io.OutputStream out)
           
 void netSetMaxThreads(int max)
          Connect to network server and set connection maxthread parameter
 void netSetTimeSlice(int timeslice)
          Set network server connection timeslice parameter
 void ping()
           
protected  void processCommands(DDMReader reader, DDMWriter writer, Session session)
          processCommands reads and processes DB2jServerImpl commands sent to the network server over the socket.
private  int processDashArg(int pos, java.lang.String[] args)
          Get the dash argument.
private  byte[] readBytesReply(java.lang.String msgKey)
          Read Bytes reply
private  void readCommandReplyHeader()
          Read the command reply header from the server
private  int readInt()
          Read int from buffer
private  byte[] readLDBytes()
          Read length delimited bytes from a buffer
private  java.lang.String readLDString()
          Read length delimited string from a buffer
private  void readResult()
          Read result from sending client message to server
private  int readShort()
          Read short from buffer
private  java.lang.String readStringReply(java.lang.String msgKey)
          Read String reply
protected  void removeFromSessionTable(int sessionid)
          Remove session from session table
protected  void runQueueAdd(Session clientSession)
          Add session to the run queue
 java.lang.String runtimeInfo()
           
private  void send()
          Send client message to server
private  void sendMessage(DDMWriter writer, int messageType, java.lang.String message)
          Send Error or Warning from server to client after processing a command
private  void sendOK(DDMWriter writer)
          Send OK from server to client after processing a command
private  void sendOKInt(DDMWriter writer, int val)
          Send OK and int value
private  void sendPropInfo(DDMWriter writer)
          Send property information from server to client
private  void sendRuntimeInfo(DDMWriter writer)
          Send RuntimeInfo information from server to client
 void sendSetTraceDirectory(java.lang.String traceDirectory)
           
private  void sendSQLMessage(DDMWriter writer, java.sql.SQLException se, int type)
          Send SQL Exception from server to client after processing a command
private  void sendSysInfo(DDMWriter writer)
          Send SysInfo information from server to client
protected  void setClientLocale(java.lang.String locale)
           
protected  void setConnectionPoolParameters(int min, int max, java.lang.String host, int portNumber)
          Set default connection pool parameters
protected  void setConnectionPoolParameters(java.lang.String database, int min, int max, java.lang.String host, int portNumber)
          Set connection pool parameters for a database
private  void setLogConnections(boolean value)
          Set the current value of logging connections
 void setLogWriter(java.io.PrintWriter outWriter)
          Set the output stream for console messages If this is set to null, no messages will be written to the console
private  void setMaxPoolSize(int value)
          Set the current value of maximum number of pooled connections to create
private  void setMaxThreads(int value)
          Set the current value of maximum number of threads to create
private  void setMinPoolSize(int value)
          Set the current value of minimum number of pooled connections to create at start
private  void setMinThreads(int value)
          Set the current value of minimum number of threads to create at start
private  void setTimeSlice(int value)
          Set the current value of time slice
private  boolean setTrace(boolean on)
          Set the trace on/off for all sessions, or one session, depending on whether we got -s argument.
private  void setTraceAll(boolean value)
          Set the current value of whether to trace all the sessions
private  void setTraceDirectory(java.lang.String value)
          Set the current value of trace directory
static void setUniqueThreadName(java.lang.Thread thrd, java.lang.String newName)
          Set a thread name to be something that is both meaningful and unique (primarily for debugging purposes).
private  void setUpSocket()
          Set up client socket to send a command to the network server
 void shutdown()
          Shutdown a network server
private  void shutdownDatabase(DDMWriter writer, java.lang.String database, java.lang.String user, java.lang.String password)
          Shutdown a database
 void start(java.io.PrintWriter consoleWriter)
          Start a network server.
private  void startDatabase(DDMWriter writer, java.lang.String database, java.lang.String bootPassword, java.lang.String encPrv, java.lang.String encAlg, java.lang.String user, java.lang.String password)
          Boot database
protected  void startDB2j()
          Load Cloudscape and save driver for future use.
protected  boolean supportsCCSID(int ccsid)
          Check whether a CCSID code page is supported
 java.lang.String sysinfo()
           
private  void throwSQLException(java.lang.String msg)
          Throw a SQL Exception which was sent over by a server Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized message
private  void throwSQLWarning(java.lang.String msg)
          Throw a SQL Warning which was sent over by a server Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized message
private  void throwUnexpectedException(java.lang.Exception e)
          Print a trace for the (unexpected) exception received, then throw a generic exception indicating that 1) an unexpected exception was thrown, and 2) we've already printed the trace (so don't do it again).
 void trace(boolean on)
          Turn tracing on or off for all sessions
 void trace(int connNum, boolean on)
          Turn tracing on or off for one session or all sessions
 void usage()
          Display usage information
private  void wrapSQLError(java.lang.String messageKey)
          Wrap SQL Error - display to console and raise exception
private  void wrapSQLWarning(java.lang.String messageKey)
          Wrap SQL Warning - display to console and raise exception
private  void writeByte(int value)
          Write byte
private  void writeCommandHeader(int command)
          Write command header consisting of command header string and protocol version and command
private  void writeCommandReplyHeader(DDMWriter writer)
          Write Command reply
private  void writeLDString(java.lang.String msg)
          Write length delimited string string
private  void writeShort(int value)
          Write short
protected  void writeString(java.lang.String msg)
          Write string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_USAGE_MSGS

private static final int NO_USAGE_MSGS
See Also:
Constant Field Values

COMMANDS

private static final java.lang.String[] COMMANDS

COMMAND_ARGS

private static final int[] COMMAND_ARGS

COMMAND_START

private static final int COMMAND_START
See Also:
Constant Field Values

COMMAND_SHUTDOWN

private static final int COMMAND_SHUTDOWN
See Also:
Constant Field Values

COMMAND_TRACE

private static final int COMMAND_TRACE
See Also:
Constant Field Values

COMMAND_TRACEDIRECTORY

private static final int COMMAND_TRACEDIRECTORY
See Also:
Constant Field Values

COMMAND_TESTCONNECTION

private static final int COMMAND_TESTCONNECTION
See Also:
Constant Field Values

COMMAND_LOGCONNECTIONS

private static final int COMMAND_LOGCONNECTIONS
See Also:
Constant Field Values

COMMAND_SYSINFO

private static final int COMMAND_SYSINFO
See Also:
Constant Field Values

COMMAND_RUNTIME_INFO

private static final int COMMAND_RUNTIME_INFO
See Also:
Constant Field Values

COMMAND_MAXTHREADS

private static final int COMMAND_MAXTHREADS
See Also:
Constant Field Values

COMMAND_TIMESLICE

private static final int COMMAND_TIMESLICE
See Also:
Constant Field Values

COMMAND_PROPERTIES

private static final int COMMAND_PROPERTIES
See Also:
Constant Field Values

COMMAND_UNKNOWN

private static final int COMMAND_UNKNOWN
See Also:
Constant Field Values

DASHARGS

private static final java.lang.String[] DASHARGS

DASHARG_PORT

private static final int DASHARG_PORT
See Also:
Constant Field Values

DASHARG_DATABASE

private static final int DASHARG_DATABASE
See Also:
Constant Field Values

DASHARG_USER

private static final int DASHARG_USER
See Also:
Constant Field Values

DASHARG_LOADSYSIBM

private static final int DASHARG_LOADSYSIBM
See Also:
Constant Field Values

DASHARG_ENCALG

private static final int DASHARG_ENCALG
See Also:
Constant Field Values

DASHARG_ENCPRV

private static final int DASHARG_ENCPRV
See Also:
Constant Field Values

DASHARG_BOOTPASSWORD

private static final int DASHARG_BOOTPASSWORD
See Also:
Constant Field Values

DASHARG_HOST

private static final int DASHARG_HOST
See Also:
Constant Field Values

DASHARG_SESSION

private static final int DASHARG_SESSION
See Also:
Constant Field Values

PROTOCOL_VERSION

private static final int PROTOCOL_VERSION
See Also:
Constant Field Values

COMMAND_HEADER

private static final java.lang.String COMMAND_HEADER
See Also:
Constant Field Values

REPLY_HEADER

private static final java.lang.String REPLY_HEADER
See Also:
Constant Field Values

REPLY_HEADER_LENGTH

private static final int REPLY_HEADER_LENGTH

OK

private static final int OK
See Also:
Constant Field Values

WARNING

private static final int WARNING
See Also:
Constant Field Values

ERROR

private static final int ERROR
See Also:
Constant Field Values

SQLERROR

private static final int SQLERROR
See Also:
Constant Field Values

SQLWARNING

private static final int SQLWARNING
See Also:
Constant Field Values

DB2J_PROP_STREAM_ERROR_FIELD

private static final java.lang.String DB2J_PROP_STREAM_ERROR_FIELD
See Also:
Constant Field Values

DB2J_PROP_STREAM_ERROR_METHOD

private static final java.lang.String DB2J_PROP_STREAM_ERROR_METHOD
See Also:
Constant Field Values

DB2J_PROP_STREAM_ERROR_FILE

private static final java.lang.String DB2J_PROP_STREAM_ERROR_FILE
See Also:
Constant Field Values

DRDA_PROP_MESSAGES

private static final java.lang.String DRDA_PROP_MESSAGES
See Also:
Constant Field Values

DRDA_PROP_DEBUG

private static final java.lang.String DRDA_PROP_DEBUG
See Also:
Constant Field Values

CLOUDSCAPE_DRIVER

private static final java.lang.String CLOUDSCAPE_DRIVER
See Also:
Constant Field Values

UNEXPECTED_ERR

protected static final java.lang.String UNEXPECTED_ERR
See Also:
Constant Field Values

MIN_MAXTHREADS

private static final int MIN_MAXTHREADS
See Also:
Constant Field Values

MIN_TIMESLICE

private static final int MIN_TIMESLICE
See Also:
Constant Field Values

USE_DEFAULT

private static final int USE_DEFAULT
See Also:
Constant Field Values

DEFAULT_MAXTHREADS

private static final int DEFAULT_MAXTHREADS
See Also:
Constant Field Values

DEFAULT_TIMESLICE

private static final int DEFAULT_TIMESLICE
See Also:
Constant Field Values

DEFAULT_HOST

private static final java.lang.String DEFAULT_HOST
See Also:
Constant Field Values

DRDA_MSG_PREFIX

private static final java.lang.String DRDA_MSG_PREFIX
See Also:
Constant Field Values

DEFAULT_LOCALE

private static final java.lang.String DEFAULT_LOCALE
See Also:
Constant Field Values

DEFAULT_LOCALE_COUNTRY

private static final java.lang.String DEFAULT_LOCALE_COUNTRY
See Also:
Constant Field Values

SHUTDOWN_CHECK_ATTEMPTS

private static final int SHUTDOWN_CHECK_ATTEMPTS
See Also:
Constant Field Values

SHUTDOWN_CHECK_INTERVAL

private static final int SHUTDOWN_CHECK_INTERVAL
See Also:
Constant Field Values

MAXREPLY

private static final int MAXREPLY
See Also:
Constant Field Values

att_srvclsnm

protected static java.lang.String att_srvclsnm

ATT_SRVNAM

protected static final java.lang.String ATT_SRVNAM
See Also:
Constant Field Values

att_extnam

protected static java.lang.String att_extnam

att_srvrlslv

protected static java.lang.String att_srvrlslv

prdId

protected static java.lang.String prdId

buildNumber

private static java.lang.String buildNumber

CCSIDSBC

protected static final int CCSIDSBC
See Also:
Constant Field Values

CCSIDMBC

protected static final int CCSIDMBC
See Also:
Constant Field Values

DEFAULT_ENCODING

protected static final java.lang.String DEFAULT_ENCODING
See Also:
Constant Field Values

DEFAULT_CCSID

protected static final int DEFAULT_CCSID
See Also:
Constant Field Values

SPACE_CHAR

protected static final byte SPACE_CHAR
See Also:
Constant Field Values

DEFAULT_SECURITY_MECHANISM

protected static final int DEFAULT_SECURITY_MECHANISM
See Also:
Constant Field Values

MGR_LEVELS

protected static final int[] MGR_LEVELS

logWriter

protected java.io.PrintWriter logWriter

cloudscapeLogWriter

protected java.io.PrintWriter cloudscapeLogWriter

cloudscapeDriver

protected java.sql.Driver cloudscapeDriver

ERRTYPE_SEVERE

private static final int ERRTYPE_SEVERE
See Also:
Constant Field Values

ERRTYPE_USER

private static final int ERRTYPE_USER
See Also:
Constant Field Values

ERRTYPE_INFO

private static final int ERRTYPE_INFO
See Also:
Constant Field Values

ERRTYPE_UNKNOWN

private static final int ERRTYPE_UNKNOWN
See Also:
Constant Field Values

commandArgs

private java.util.Vector commandArgs

databaseArg

private java.lang.String databaseArg

userArg

private java.lang.String userArg

passwordArg

private java.lang.String passwordArg

bootPasswordArg

private java.lang.String bootPasswordArg

encAlgArg

private java.lang.String encAlgArg

encPrvArg

private java.lang.String encPrvArg

hostArg

private java.lang.String hostArg

hostAddress

private java.net.InetAddress hostAddress

sessionArg

private int sessionArg

mc

private memCheck mc

replyBuffer

private byte[] replyBuffer

replyBufferCount

private int replyBufferCount

replyBufferPos

private int replyBufferPos

portNumber

private int portNumber

traceDirectory

private java.lang.String traceDirectory

traceDirectorySync

private java.lang.Object traceDirectorySync

traceAll

private boolean traceAll

traceAllSync

private java.lang.Object traceAllSync

serverStartSync

private java.lang.Object serverStartSync

logConnections

private boolean logConnections

logConnectionsSync

private java.lang.Object logConnectionsSync

minThreads

private int minThreads

maxThreads

private int maxThreads

threadsSync

private java.lang.Object threadsSync

timeSlice

private int timeSlice

timeSliceSync

private java.lang.Object timeSliceSync

keepAlive

private boolean keepAlive

minPoolSize

private int minPoolSize

maxPoolSize

private int maxPoolSize

poolSync

private java.lang.Object poolSync

debugOutput

protected boolean debugOutput

cleanupOnStart

private boolean cleanupOnStart

restartFlag

private boolean restartFlag

errorLogLocation

private java.lang.String errorLogLocation

clientSocket

private java.net.Socket clientSocket

clientIs

private java.io.InputStream clientIs

clientOs

private java.io.OutputStream clientOs

byteArrayOs

private java.io.ByteArrayOutputStream byteArrayOs

commandOs

private java.io.DataOutputStream commandOs

shutdownSync

private java.lang.Object shutdownSync

shutdown

private boolean shutdown

connNum

private int connNum

serverSocket

private java.net.ServerSocket serverSocket

serverInstance

private DB2jServerImpl serverInstance

langUtil

private LocalizedResource langUtil

clientLocale

public java.lang.String clientLocale

localAddresses

java.util.ArrayList localAddresses

sessionTable

private java.util.Hashtable sessionTable

currentSession

private Session currentSession

threadList

private java.util.Vector threadList

runQueue

private java.util.Vector runQueue

freeThreads

private int freeThreads

appRequesterTable

private java.util.Hashtable appRequesterTable

propertyFileName

private java.lang.String propertyFileName

acceptClients

private java.lang.Runnable acceptClients
Constructor Detail

DB2jServerImpl

public DB2jServerImpl()
               throws java.lang.Exception

DB2jServerImpl

public DB2jServerImpl(java.net.InetAddress address,
                      int portNumber)
               throws java.lang.Exception
Internal constructor for NetworkServerControl API.

See Also:
NetworkServerControl
Method Detail

init

private void init()
           throws java.lang.Exception
Throws:
java.lang.Exception

makePrintWriter

private java.io.PrintWriter makePrintWriter(java.io.OutputStream out)

setLogWriter

public void setLogWriter(java.io.PrintWriter outWriter)
Set the output stream for console messages If this is set to null, no messages will be written to the console


consoleError

public void consoleError(java.lang.String msg)
                  throws java.lang.Exception
Write an error message to console output stream and throw an exception for this error

Parameters:
msg - error message
Throws:
java.lang.Exception

consoleExceptionPrint

public void consoleExceptionPrint(java.lang.Exception e)
Write an exception to console output stream, but only if debugOutput is true.

Parameters:
e - exception

consoleExceptionPrintTrace

public void consoleExceptionPrintTrace(java.lang.Throwable e)
Write an exception (with trace) to console output stream.

Parameters:
e - exception

consoleMessage

public void consoleMessage(java.lang.String msg)
Write a message to console output stream

Parameters:
msg - message

start

public void start(java.io.PrintWriter consoleWriter)
           throws java.lang.Exception
Start a network server. Launches a separate thread with DRDAServerStarter. Want to use Monitor.startModule, so it can all get shutdown when cloudscape shuts down, but can't get it working right now.

Parameters:
consoleWriter - PrintWriter to which server console will be output. Null will disable console output.
Throws:
java.lang.Exception - throws an exception if an error occurs

blockingStart

public void blockingStart(java.io.PrintWriter consoleWriter)
                   throws java.lang.Exception
Start a network server

Parameters:
consoleWriter - PrintWriter to which server console will be output. Null will disable console output.
Throws:
java.lang.Exception - throws an exception if an error occurs

startDB2j

protected void startDB2j()
                  throws java.lang.Exception
Load Cloudscape and save driver for future use. We can't call Driver Manager when the client connects, because they might be holding the DriverManager lock.

Throws:
java.lang.Exception

shutdown

public void shutdown()
              throws java.lang.Exception
Shutdown a network server

Throws:
java.lang.Exception - throws an exception if an error occurs

directShutdown

public void directShutdown()

isServerStarted

public boolean isServerStarted()
                        throws java.lang.Exception
Throws:
java.lang.Exception

ping

public void ping()
          throws java.lang.Exception
Throws:
java.lang.Exception

trace

public void trace(boolean on)
           throws java.lang.Exception
Turn tracing on or off for all sessions

Parameters:
on - true to turn tracing on, false to turn tracing off
Throws:
java.lang.Exception - throws an exception if an error occurs

trace

public void trace(int connNum,
                  boolean on)
           throws java.lang.Exception
Turn tracing on or off for one session or all sessions

Parameters:
connNum - the connNum of the session, 0 if all sessions
on - true to turn tracing on, false to turn tracing off
Throws:
java.lang.Exception - throws an exception if an error occurs

consoleTraceMessage

private void consoleTraceMessage(int connNum,
                                 boolean on)
                          throws java.lang.Exception
Print trace change message to console

Parameters:
on - true to print tracing on, false to print tracing off
Throws:
java.lang.Exception - throws an exception if an error occurs

logConnections

public void logConnections(boolean on)
                    throws java.lang.Exception
Turn logging connections on or off. When logging is turned on a message is written to DB2j.log each time a connection connects or disconnects.

Parameters:
on - true to turn on, false to turn off
Throws:
java.lang.Exception - throws an exception if an error occurs

sendSetTraceDirectory

public void sendSetTraceDirectory(java.lang.String traceDirectory)
                           throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
NetworkServerControl.setTraceDirectory(java.lang.String)

sysinfo

public java.lang.String sysinfo()
                         throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
NetworkServerControl.getSysinfo()

runtimeInfo

public java.lang.String runtimeInfo()
                             throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
NetworkServerControl#runtimeinfo

usage

public void usage()
Display usage information


setConnectionPoolParameters

protected void setConnectionPoolParameters(java.lang.String database,
                                           int min,
                                           int max,
                                           java.lang.String host,
                                           int portNumber)
                                    throws java.lang.Exception
Set connection pool parameters for a database

Parameters:
database - database parameters applied to
min - minimum number of connections, if 0, pooled connections not used if -1, use default
max - maximum number of connections, if 0, pooled connections created when no free connection available, if -1, use default
host - machine network server is running on, if null, localhost is used
portNumber - port number server is to use, if <= 0, default port number is used
Throws:
java.lang.Exception - throws an exception if an error occurs

setConnectionPoolParameters

protected void setConnectionPoolParameters(int min,
                                           int max,
                                           java.lang.String host,
                                           int portNumber)
                                    throws java.lang.Exception
Set default connection pool parameters

Parameters:
min - minimum number of connections, if 0, pooled connections not used if -1, use default
max - maximum number of connections, if 0, pooled connections created when no free connection available if -1, use default
host - machine network server is running on, if null, localhost is used
portNumber - port number server is to use, if <= 0, default port number is used
Throws:
java.lang.Exception - throws an exception if an error occurs

netSetMaxThreads

public void netSetMaxThreads(int max)
                      throws java.lang.Exception
Connect to network server and set connection maxthread parameter

Parameters:
max - maximum number of connections, if 0, connections created when no free connection available if -1, use default
Throws:
java.lang.Exception - throws an exception if an error occurs

netSetTimeSlice

public void netSetTimeSlice(int timeslice)
                     throws java.lang.Exception
Set network server connection timeslice parameter

Parameters:
timeslice - amount of time given to each session before yielding to another session, if 0, never yield. if -1, use default.
Throws:
java.lang.Exception - throws an exception if an error occurs

getCurrentProperties

public java.util.Properties getCurrentProperties()
                                          throws java.lang.Exception
Get current properties

Returns:
Properties object containing properties
Throws:
java.lang.Exception - throws an exception if an error occurs

setUniqueThreadName

public static void setUniqueThreadName(java.lang.Thread thrd,
                                       java.lang.String newName)
Set a thread name to be something that is both meaningful and unique (primarily for debugging purposes).

Parameters:
thrd - An instance of a Thread object that still has its default thread name (as generated by the jvm Thread constructor). This should always be of the form "Thread-N", where N is a unique thread id generated by the jvm. Ex. "Thread-0", "Thread-1", etc.
Returns:
The received thread's name has been set to a new string of the form [newName + "_n"], where 'n' is a unique thread id originally generated by the jvm Thread constructor. If the default name of the thread has been changed before getting here, then nothing is done.

removeFromSessionTable

protected void removeFromSessionTable(int sessionid)
Remove session from session table

Parameters:
sessionid - id of session to be removed

processCommands

protected void processCommands(DDMReader reader,
                               DDMWriter writer,
                               Session session)
                        throws java.lang.Throwable
processCommands reads and processes DB2jServerImpl commands sent to the network server over the socket. The protocol used is 4 bytes - String CMD: 2 bytes - Protocol version 1 byte - length of locale (0 for default) n bytes - locale 1 byte - length of codeset (0 for default) n bytes - codeset 1 byte - command n bytes - parameters for the command The server returns 4 bytes - String RPY: for most commands 1 byte - command result, 0 - OK, 1 - warning, 2 - error if warning or error 1 bytes - length of message key n bytes - message key 1 byte - number of parameters to message {2 bytes - length of parameter n bytes - parameter} for each parameter for sysinfo 1 byte - command result, 0 - OK, 1 - warning, 2 - error if OK 2 bytes - length of sysinfo n bytes - sysinfo Note, the 3rd byte of the command must not be 'D0' to distinquish it from DSS structures. The protocol for the parameters for each command follows: Command: trace {on | off} Protocol: 4 bytes - connection id - connection id of 0 means all sessions 1 byte - 0 off, 1 on Command: logConnections {on | off} Protocol: 1 byte - 0 off, 1 on Command: shutdown No parameters Command: sysinfo No parameters Command: dbstart Protocol: 2 bytes - length of database name n bytes - database name 2 bytes - length of boot password n bytes - boot password 2 bytes - length of encryption algorithm n bytes - encryption algorithm 2 bytes - length of encryption provider n bytes - encryption provider 2 bytes - length of user name n bytes - user name 2 bytes - length of password n bytes - password Command: dbshutdown Protocol: 2 bytes - length of database name n bytes - database name 2 bytes - length of user name n bytes - user name 2 bytes - length of password n bytes - password Command: connpool Protocol: 2 bytes - length of database name, if 0, default for all databases is set n bytes - database name 2 bytes - minimum number of connections, if 0, connection pool not used if value is -1 use default 2 bytes - maximum number of connections, if 0, connections are created as needed, if value is -1 use default Command: maxthreads Protocol: 2 bytes - maximum number of threads Command: timeslice Protocol: 4 bytes - timeslice value Command: tracedirectory Protocol: 2 bytes - length of directory name n bytes - directory name Command: test connection Protocol: 2 bytes - length of database name if 0, just the connection to the network server is tested and user name and password aren't sent n bytes - database name 2 bytes - length of user name (optional) n bytes - user name 2 bytes - length of password (optional) n bytes - password The calling routine is synchronized so that multiple threads don't clobber each other. This means that configuration commands will be serialized. This shouldn't be a problem since they should be fairly rare.

Parameters:
reader - input reader for command
writer - output writer for command
session - session information
Throws:
java.lang.Throwable - throws an exception if an error occurs

getNextSession

protected Session getNextSession(Session currentSession)
Get the next session for the thread to work on Called from DRDAConnThread after session completes or timeslice exceeded. If there is a waiting session, pick it up and put currentSession at the back of the queue if there is one.

Parameters:
currentSession - session thread is currently working on
Returns:
next session to work on, could be same as current session

getAppRequester

protected AppRequester getAppRequester(AppRequester appRequester)
Get the stored application requester or store if we haven't seen it yet

Parameters:
appRequester - Application Requester to look for
Returns:
stored application requester

getManagerLevel

protected int getManagerLevel(int manager)
Get the server manager level for a given manager

Returns:
manager level

supportsCCSID

protected boolean supportsCCSID(int ccsid)
Check whether a CCSID code page is supported

Returns:
true if supported; false otherwise

consolePropertyMessage

protected void consolePropertyMessage(java.lang.String msgProp)
                               throws java.lang.Exception
Put property message on console

Parameters:
msgProp - message property key
Throws:
throws - an Exception if an error occurs
java.lang.Exception

consolePropertyMessage

protected void consolePropertyMessage(java.lang.String msgProp,
                                      java.lang.String arg)
                               throws java.lang.Exception
Put property message on console

Parameters:
msgProp - message property key
arg - argument for message
Throws:
throws - an Exception if an error occurs
java.lang.Exception

consolePropertyMessage

protected void consolePropertyMessage(java.lang.String msgProp,
                                      java.lang.String[] args)
                               throws java.lang.Exception
Put property message on console

Parameters:
msgProp - message property key
args - argument array for message
Throws:
throws - an Exception if an error occurs
java.lang.Exception

isCmd

protected static boolean isCmd(java.lang.String val)
Is this the command protocol

Parameters:
val -

writeCommandReplyHeader

private void writeCommandReplyHeader(DDMWriter writer)
                              throws java.lang.Exception
Write Command reply

Parameters:
writer - writer to use
Throws:
throws - Exception if a problem occurs sending OK
java.lang.Exception

sendOK

private void sendOK(DDMWriter writer)
             throws java.lang.Exception
Send OK from server to client after processing a command

Parameters:
writer - writer to use for sending OK
Throws:
throws - Exception if a problem occurs sending OK
java.lang.Exception

sendOKInt

private void sendOKInt(DDMWriter writer,
                       int val)
                throws java.lang.Exception
Send OK and int value

Parameters:
writer - writer to use for sending
val - int val to send
Throws:
throws - Exception if a problem occurs
java.lang.Exception

sendMessage

private void sendMessage(DDMWriter writer,
                         int messageType,
                         java.lang.String message)
                  throws java.lang.Exception
Send Error or Warning from server to client after processing a command

Parameters:
writer - writer to use for sending message
messageType - 1 for Warning, 2 for Error 3 for SQLError
message - message
Throws:
throws - Exception if a problem occurs sending message
java.lang.Exception

sendSQLMessage

private void sendSQLMessage(DDMWriter writer,
                            java.sql.SQLException se,
                            int type)
                     throws java.lang.Exception
Send SQL Exception from server to client after processing a command

Parameters:
writer - writer to use for sending message
se - Cloudscape exception
type - type of exception, SQLERROR or SQLWARNING
Throws:
throws - Exception if a problem occurs sending message
java.lang.Exception

sendSysInfo

private void sendSysInfo(DDMWriter writer)
                  throws java.lang.Exception
Send SysInfo information from server to client

Parameters:
writer - writer to use for sending sysinfo
Throws:
throws - Exception if a problem occurs sending value
java.lang.Exception

sendRuntimeInfo

private void sendRuntimeInfo(DDMWriter writer)
                      throws java.lang.Exception
Send RuntimeInfo information from server to client

Parameters:
writer - writer to use for sending sysinfo
Throws:
throws - Exception if a problem occurs sending value
java.lang.Exception

sendPropInfo

private void sendPropInfo(DDMWriter writer)
                   throws java.lang.Exception
Send property information from server to client

Parameters:
writer - writer to use for sending sysinfo
Throws:
throws - Exception if a problem occurs sending value
java.lang.Exception

getNetSysInfo

private java.lang.String getNetSysInfo()
Get Net Server information

Returns:
system information for the Network Server

getRuntimeInfo

private java.lang.String getRuntimeInfo()
See Also:
NetworkServerControl.getRuntimeInfo()

getCLSSysInfo

private java.lang.String getCLSSysInfo()
                                throws java.io.IOException
Get Cloudscape information

Returns:
system information for Cloudscape
Throws:
throws - IOException if a problem occurs encoding string
java.io.IOException

execute

public static void execute(java.lang.String[] args)
Execute the command given on the command line

Parameters:
args - array of arguments indicating command to be executed
Throws:
java.lang.Exception - throws an exception if an error occurs see class comments for more information

executeWork

protected void executeWork(java.lang.String[] args)
                    throws java.lang.Exception
Execute the command given on the command line

Parameters:
args - array of arguments indicating command to be executed
Throws:
java.lang.Exception - throws an exception if an error occurs see class comments for more information

runQueueAdd

protected void runQueueAdd(Session clientSession)
Add session to the run queue

Parameters:
clientSession - session needing work

findCommand

private int findCommand(java.lang.String[] args)
                 throws java.lang.Exception
Go through the arguments and find the command and save the dash arguments and arguments to the command. Only one command is allowed in the argument list.

Parameters:
args - arguments to search
Returns:
command
Throws:
java.lang.Exception

processDashArg

private int processDashArg(int pos,
                           java.lang.String[] args)
                    throws java.lang.Exception
Get the dash argument. Optional arguments are formated as -x value.

Parameters:
pos - starting point
args - arguments to search
Returns:
command
Throws:
java.lang.Exception - thrown if an error occurs

isOn

private boolean isOn(java.lang.String arg)
              throws java.lang.Exception
Is string "on" or "off"

Returns:
true if string is "on", false if string is "off"
Throws:
java.lang.Exception - thrown if string is not one of "on" or "off"

setUpSocket

private void setUpSocket()
                  throws java.lang.Exception
Set up client socket to send a command to the network server

Throws:
java.lang.Exception - thrown if exception encountered

checkAddressIsLocal

private void checkAddressIsLocal(java.net.InetAddress inetAddr)
                          throws java.net.UnknownHostException,
                                 java.lang.Exception
Throws:
java.net.UnknownHostException
java.lang.Exception

buildLocalAddressList

private void buildLocalAddressList(java.net.InetAddress bindAddr)
Build local address list to allow admin commands.

Parameters:
bindAddr - Address on which server was started Note: Some systems may not support localhost. In that case a console message will print for the localhost entries, but the server will continue to start.

writeCommandHeader

private void writeCommandHeader(int command)
                         throws java.lang.Exception
Write command header consisting of command header string and protocol version and command

Parameters:
command - command to be written
Throws:
java.lang.Exception - throws an exception if an error occurs

writeLDString

private void writeLDString(java.lang.String msg)
                    throws java.lang.Exception
Write length delimited string string

Parameters:
msg - string to be written
Throws:
java.lang.Exception - throws an exception if an error occurs

writeString

protected void writeString(java.lang.String msg)
                    throws java.lang.Exception
Write string

Parameters:
msg - String to write
Throws:
java.lang.Exception

writeShort

private void writeShort(int value)
                 throws java.lang.Exception
Write short

Parameters:
value - value to be written
Throws:
java.lang.Exception - throws an exception if an error occurs

writeByte

private void writeByte(int value)
                throws java.lang.Exception
Write byte

Parameters:
value - value to be written
Throws:
java.lang.Exception - throws an exception if an error occurs

send

private void send()
           throws java.lang.Exception
Send client message to server

Throws:
java.lang.Exception - throws an exception if an error occurs

clientSocketError

private void clientSocketError(java.io.IOException e)
                        throws java.io.IOException
Stream error writing to client socket

Throws:
java.io.IOException

readResult

private void readResult()
                 throws java.lang.Exception
Read result from sending client message to server

Throws:
java.lang.Exception - throws an exception if an error occurs

ensureDataInBuffer

private void ensureDataInBuffer(int minimumBytesNeeded)
                         throws java.lang.Exception
Ensure the reply buffer is at large enought to hold all the data; don't just rely on OS level defaults

Parameters:
minimumBytesNeeded - size of buffer required
Throws:
java.lang.Exception - throws an exception if a problem reading the reply

fillReplyBuffer

private void fillReplyBuffer()
                      throws java.lang.Exception
Fill the reply buffer with the reply allocates a reply buffer if one doesn't exist

Throws:
java.lang.Exception - throws an exception if a problem reading the reply

readCommandReplyHeader

private void readCommandReplyHeader()
                             throws java.lang.Exception
Read the command reply header from the server

Throws:
java.lang.Exception - throws an exception if an error occurs

readShort

private int readShort()
               throws java.lang.Exception
Read short from buffer

Throws:
java.lang.Exception - throws an exception if an error occurs

readInt

private int readInt()
             throws java.lang.Exception
Read int from buffer

Throws:
java.lang.Exception - throws an exception if an error occurs

readStringReply

private java.lang.String readStringReply(java.lang.String msgKey)
                                  throws java.lang.Exception
Read String reply

Parameters:
msgKey - error message key
Returns:
string value or null
Throws:
java.lang.Exception - throws an error if problems reading reply

readLDString

private java.lang.String readLDString()
                               throws java.lang.Exception
Read length delimited string from a buffer

Returns:
string value from buffer
Throws:
java.lang.Exception - throws an error if problems reading reply

readBytesReply

private byte[] readBytesReply(java.lang.String msgKey)
                       throws java.lang.Exception
Read Bytes reply

Parameters:
msgKey - error message key
Returns:
string value or null
Throws:
java.lang.Exception - throws an error if problems reading reply

readLDBytes

private byte[] readLDBytes()
                    throws java.lang.Exception
Read length delimited bytes from a buffer

Returns:
byte array from buffer
Throws:
java.lang.Exception - throws an error if problems reading reply

getPropertyInfo

private void getPropertyInfo()
                      throws java.lang.Exception
Get property info

Returns:
system properties
Throws:
java.lang.Exception

getIntPropVal

private int getIntPropVal(java.lang.String propName,
                          java.lang.String propVal)
                   throws java.lang.Exception
Get integer property values

Parameters:
propName - property name
propVal - string property value
Returns:
integer value
Throws:
java.lang.Exception - if not a valid integer

consolePropertyMessageWork

private void consolePropertyMessageWork(java.lang.String messageKey,
                                        java.lang.String[] args)
                                 throws java.lang.Exception
Handle console error message - display on console and if it is a user error, display usage - if user error or severe error, throw exception with message key and message

Parameters:
messageKey - message key
args - arguments to message
Throws:
throws - an Exception if an error occurs
java.lang.Exception

throwSQLException

private void throwSQLException(java.lang.String msg)
                        throws java.sql.SQLException
Throw a SQL Exception which was sent over by a server Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized message

Parameters:
msg - msg containing SQL Exception
Throws:
throws - a SQLException
java.sql.SQLException

throwSQLWarning

private void throwSQLWarning(java.lang.String msg)
                      throws java.sql.SQLWarning
Throw a SQL Warning which was sent over by a server Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized message

Parameters:
msg - msg containing SQL Warning
Throws:
throws - a SQLWarning
java.sql.SQLWarning

throwUnexpectedException

private void throwUnexpectedException(java.lang.Exception e)
                               throws java.lang.Exception
Print a trace for the (unexpected) exception received, then throw a generic exception indicating that 1) an unexpected exception was thrown, and 2) we've already printed the trace (so don't do it again).

Parameters:
e - An unexpected exception.
Throws:
throws - an Exception with message UNEXPECTED_ERR.
java.lang.Exception

localizeMessage

private java.lang.String localizeMessage(java.lang.String msgProp,
                                         LocalizedResource localLangUtil,
                                         java.lang.String[] args)
Localize a message given a particular AppUI

Parameters:
msgProp - message key
args - arguments to message

getMessageType

private int getMessageType(java.lang.String msg)
Determine type of message

Parameters:
msg - message
Returns:
message type

isMsgProperty

private boolean isMsgProperty(java.lang.String msg)
Determine whether string is a property key or not property keys start with DRDA_MSG_PREFIX

Parameters:
msg - message
Returns:
true if it is a property key; false otherwise

getLogConnections

public boolean getLogConnections()
Get the current value of logging connections

Returns:
true if logging connections is on; false otherwise

setLogConnections

private void setLogConnections(boolean value)
Set the current value of logging connections

Parameters:
value - true to turn logging connections on; false to turn it off

setTrace

private boolean setTrace(boolean on)
Set the trace on/off for all sessions, or one session, depending on whether we got -s argument.

Parameters:
on - true to turn trace on; false to turn it off
Returns:
true if set false if an error occurred

getTimeSlice

protected int getTimeSlice()
Get the current value of the time slice

Returns:
time slice value

setTimeSlice

private void setTimeSlice(int value)
                   throws java.lang.Exception
Set the current value of time slice

Parameters:
value - time slice value
Throws:
java.lang.Exception - if value is < 0

getKeepAlive

protected boolean getKeepAlive()
Get the current value of keepAlive to configure how long the server should keep the socket alive for a disconnected client


getMinThreads

private int getMinThreads()
Get the current value of minimum number of threads to create at start

Returns:
value of minimum number of threads

setMinThreads

private void setMinThreads(int value)
Set the current value of minimum number of threads to create at start

Parameters:
value - value of minimum number of threads

getMaxThreads

protected int getMaxThreads()
Get the current value of maximum number of threads to create

Returns:
value of maximum number of threads

setMaxThreads

private void setMaxThreads(int value)
                    throws java.lang.Exception
Set the current value of maximum number of threads to create

Parameters:
value - value of maximum number of threads
Throws:
java.lang.Exception - if value is less than 0

getMinPoolSize

private int getMinPoolSize()
Get the current value of minimum number of pooled connections to create at start

Returns:
value of minimum number of pooled connections

setMinPoolSize

private void setMinPoolSize(int value)
Set the current value of minimum number of pooled connections to create at start

Parameters:
value - value of minimum number of pooled connections

getMaxPoolSize

private int getMaxPoolSize()
Get the current value of maximum number of pooled connections to create

Returns:
value of maximum number of pooled connections

setMaxPoolSize

private void setMaxPoolSize(int value)
Set the current value of maximum number of pooled connections to create

Parameters:
value - value of maximum number of pooled connections

getTraceAll

protected boolean getTraceAll()
Get the current value of whether to trace all the sessions

Returns:
true if tracing is on for all sessions; false otherwise

setTraceAll

private void setTraceAll(boolean value)
Set the current value of whether to trace all the sessions

Parameters:
value - true if tracing is on for all sessions; false otherwise

getTraceDirectory

protected java.lang.String getTraceDirectory()
Get the current value of trace directory

Returns:
trace directory

setTraceDirectory

private void setTraceDirectory(java.lang.String value)
Set the current value of trace directory

Parameters:
value - trace directory

connectToDatabase

private void connectToDatabase(DDMWriter writer,
                               java.lang.String database,
                               java.lang.String user,
                               java.lang.String password)
                        throws java.lang.Exception
Connect to a database to test whether a connection can be made

Parameters:
writer - connection to send message to
database - database directory to connect to
user - user to use
password - password to use
Throws:
java.lang.Exception

startDatabase

private void startDatabase(DDMWriter writer,
                           java.lang.String database,
                           java.lang.String bootPassword,
                           java.lang.String encPrv,
                           java.lang.String encAlg,
                           java.lang.String user,
                           java.lang.String password)
                    throws java.lang.Exception
Boot database

Parameters:
writer - connection to send message to
database - database directory to connect to
bootPassword - boot password
encPrv - encryption provider
encAlg - encryption algorithm
user - user to use
password - password to use
Throws:
java.lang.Exception

shutdownDatabase

private void shutdownDatabase(DDMWriter writer,
                              java.lang.String database,
                              java.lang.String user,
                              java.lang.String password)
                       throws java.lang.Exception
Shutdown a database

Parameters:
writer - connection to send message to
database - database directory to shutdown to
user - user to use
password - password to use
Throws:
java.lang.Exception

wrapSQLError

private void wrapSQLError(java.lang.String messageKey)
                   throws java.lang.Exception
Wrap SQL Error - display to console and raise exception

Parameters:
messageKey - Cloudscape SQL Exception message id
Throws:
java.lang.Exception - raises exception for message

wrapSQLWarning

private void wrapSQLWarning(java.lang.String messageKey)
                     throws java.lang.Exception
Wrap SQL Warning - display to console and raise exception

Parameters:
messageKey - Cloudscape SQL Exception message id
Throws:
java.lang.Exception - raises exception for message

getPropertyValues

private java.util.Properties getPropertyValues()

getErrorLogLocation

public java.lang.String getErrorLogLocation()

addToSessionTable

protected void addToSessionTable(java.lang.Integer i,
                                 Session s)
Add To Session Table - for use by ClientThread, add a new Session to the sessionTable.

Parameters:
s - Session to add to the sessionTable

getNewConnNum

protected int getNewConnNum()
Get New Conn Num - for use by ClientThread, generate a new connection number for the attempted Session.

Returns:
a new connection number

getFreeThreads

protected int getFreeThreads()
Get Free Threads - for use by ClientThread, get the number of free threads in order to determine if a new thread can be run.

Returns:
the number of free threads

getThreadList

protected java.util.Vector getThreadList()
Get Thread List - for use by ClientThread, get the thread list Vector so that a newly spawned thread can be run and added to the ThreadList from the ClientThread

Returns:
the threadList Vector

getShutdownSync

protected java.lang.Object getShutdownSync()

getShutdown

protected boolean getShutdown()

buildRuntimeInfo

public java.lang.String buildRuntimeInfo(LocalizedResource locallangUtil)

setClientLocale

protected void setClientLocale(java.lang.String locale)

getNetProductVersionHolder

private ProductVersionHolder getNetProductVersionHolder()
                                                 throws java.lang.Exception
Retrieve product version information We need to make sure that this method gets the stream and passes it to ProductVersionHolder, because it lives in the Network Server jar and won't be readily available to ProductVersionHolder when running under security manager.

Throws:
java.lang.Exception


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.