Running the SimpleNetworkClientSample program
Derby Server and Administration Guide
57
java org.apache.derby.tools.sysinfo
This command displays the Derby jar files that are in the classpath.
4. After you set up your environment correctly, run the SimpleNetworkServerSample
program from the same directory:
java SimpleNetworkServerSample
If the program runs successfully, you will receive output that is similar to that shown
in the following exampleS:
Starting Network Server
Testing if Network Server is up and running!
Derby Network Server now running
Got an embedded connection.
Testing embedded connection by executing a sample query
number of rows in sys.systables = 16
While my app is busy with embedded work, ij might connect like this:
$ java -Dij.user=me -Dij.password=pw -Dij.protocol=
jdbc:derby:\\localhost:1527\ org.apache.derby.tools.ij
ij> connect 'NSSimpleDB';
Clients can continue to connect:
Press [Enter] to stop Server
Running the SimpleNetworkServerSample program also creates the following new
directories and files:
NSSimpleDB
This directory makes up the NSSimpleDB database.
derby.log
This log file contains Derby progress and error messages.
Connecting a client to the Network Server with the SimpleNetworkClientSample program
The SimpleNetworkClientSample program is a client program that interacts with the
Derby Network Server from another JVM. The program performs the following tasks:
· 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.)
· Obtains a client connection by using the DriverManager.
· Obtains a client connection by using a DataSource.
· Tests the database connections by running a sample query.
· Closes the connections and then exits the program.
You must install the following files in the
%DERBY_HOME%\demo\nserverdemo\
directory before you can run the sample program:
· The source file:
SimpleNetworkClientSample.java.
· The compiled class file:
SimpleNetworkClientSample.class.
Running the SimpleNetworkClientSample program
To connect to the Network Server that has been started with the
SimpleNetworkServerSample program:
1. Open a command prompt and change directories to
the%DERBY_HOME%\demo\nserverdemo directory, where %DERBY_HOME% is
the directory where you installed Derby.
2. Set the classpath to include the following jar files:
· The current directory (".")
· derbyclient.jar
3. After you set up your environment correctly, run the SimpleNetworkClientSample
program from the same directory: