background image
<< Controlling logging by using the log file | Running the NsSample sample program >>

Derby Network Server sample programs

<< Controlling logging by using the log file | Running the NsSample sample program >>
Derby Server and Administration Guide
53
Alternatively, while the Network Server is running, enter the following command to
set the trace directory:
java org.apache.derby.drda.NetworkServerControl traceDirectory
<directory for tracing files> [-h <hostname>] [-p <portnumber>]
You need to specify only the directory where the tracing files will reside. The names
of the tracing files are determined by the system. If you do not set a trace directory,
the tracing files will be placed in derby.system.home.
The Network Server will attempt to create the trace directory (and any parent
directories) if they do not exist. This will require that the Java security policy for
derbynet.jar
permits verification of the existence of the named trace directory
and all necessary parent directories. For each directory created, the policy must
allow
permission java.io.FilePermission "<directory>", "read,write";
and for the trace directory itself, the policy must allow
permission java.io.FilePermission "<tracedirectory>${/}-",
"write";
See
Customizing the Network Server's security policy
for information about
customizing the Network Server's security policy.
Turning off the trace facility
Enter the following command to turn off tracing:
java org.apache.derby.drda.NetworkServerControl trace off [-s <connection
number
>]
[-h <hostname>] [-p <portnumber>]
The tracing files are named ServerX.trace, where X is a connection number.
Derby Network Server sample programs
This section describes several Derby Network Server sample programs for Network
Server users.
The NsSample sample program
The NsSample demonstration program is a simple JDBC application that interacts with
the Network Server.
The NsSample program performs the following tasks:
· Starts the Network Server.
· Checks that the Network Server is running.
· Loads the Network Client driver. (Note that this step is not necessary if you are
running the client on JDK 1.6 or higher. In that environment, the network client
driver loads automatically.)
· Creates the NsSampledb database if not already created.
· Checks to see if the schema is already created, and if not, creates the schema
which includes the SAMPLETBL table and corresponding indexes.
· Connects to the database.
· Loads the schema by inserting data.