Running the Derby Server Demo
To run the SimpleNetworkServerSample.java program, open a DOS console and change directory to the nserverdemo folder. On my installation, this is contained in the following path:
When you're in this directory, type the following commands:
javac SimpleNetworkServerSample.java java SimpleNetworkServerSample
If all is well, you should see something like that illustrated in Listing 1.
Listing 1 Server Demo Program Output
C:\java\db-derby-10.1.2.1-bin\demo\nserverdemo>java SimpleNetworkServerSample Starting Network Server Testing if Network Server is up and running! Derby Network Server now running Derby connection URL: jdbc:derby:TestDB;create=true; 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 'TestDB'; Clients can continue to connect: Press [Enter] to stop Server
We'll soon look at the code that produces the output in Listing 1. You might notice a longish delay (1-2 minutes) once the second line appears. This reflects the fact that the program is trying to run the network version of Derby. As you can see at the end of Listing 1, if you want to exit the program, just press the <Enter> key. The server is now ready to receive a client connection, so let's now get a client to connect to the waiting server.