background image
<< Derby Network Server sample programs | java org.apache.derby.tools.sysinfo >>

Running the NsSample sample program

<< Derby Network Server sample programs | java org.apache.derby.tools.sysinfo >>
Derby Server and Administration Guide
54
· Starts client threads to perform database related operations.
· Has each of the clients perform DML operations (select, insert, delete, update)
using JDBC calls. For example, one client thread establishes an embedded
connection to perform database operations, while another client thread establishes
a client connection to the Network Server to perform database operations.
· Waits for the client threads to finish the tasks.
· Shuts down the Network Server at the end of the demonstration.
You must install the following files in the
%DERBY_HOME%\demo\nserverdemo\
directory before you can run the sample program:
·
NsSample.java
This is the entry point into the sample program. The program starts up two client
threads. The first client establishes an embedded connection to perform database
operations, and the second client establishes a client connection to the Network
Server to perform database operations.
You can change the following constants to modify the sample program:
NUM_ROWS
The number of rows that must be initially loaded into the schema.
ITERATIONS
The number of iterations for which each client thread does database related work.
NUM_CLIENT_THREADS
The number of clients that you want to run the program against.
NETWORKSERVER_PORT
The port on which the Network Server is running.
·
NsSampleClientThread.java
This file contains two Java classes:
· The NsSampleClientThread class extends Thread and instantiates a
NsSampleWork instance.
· The NsSampleWork class contains everything that is required to perform DML
operations using JDBC calls. The doWork method in the NsSampleWork class
represents all the work done as part of this sample program.
·
NetworkServerUtil.java
This file contains helper methods to start the Network Server and to shutdown the
server.
The compiled class files for the NsSample program are:
·
NsSample.class
·
NsSampleClientThread.class
·
NsSampleWork.class
·
NetworkServerUtil.class
Running the NsSample sample program
To run the NsSample program:
1. Open a command prompt and change directories to the %DERBY_HOME%\demo\
directory, where %DERBY_HOME% is the directory where you installed Derby.
2. Set the CLASSPATH to the current directory (".") and also include the following jar
files in order to use the Network Server and the network client driver:
derbynet.jar
The Network Server jar file. It must be in your CLASSPATH to use any of the
Network Server functions.
derbyclient.jar
This jar file must be in your CLASSPATH to use the Network Client driver.
derby.jar
The Derby database engine jar file.