This activity demonstrates the ease with which a program that embeds Derby can be modified for a client/server implementation that uses the Derby Network Server.
You use two command windows (Server-Shell and Client-Shell) in this activity. You use the Server-Shell to start the Derby Network Server and display Network Server messages. You use the Client-Shell to edit, compile and run the newly created WwdClient.java program. You set the CLASSPATH environment variable in the Client-Shell to support the client JDBC program.
In a client/server environment, the client program is often used from other computers on the network. Whenever a system accepts connections from other computers, there is a chance of abuse. To maintain security, the Derby Network Server defaults to accepting connections only from clients running on the local machine (localhost). Before this or any other Derby client program can access the Network Server from another machine, additional steps should be taken to secure the Network Server environment. Once secured, the Network Server can be safely configured to accept connections from other machines. Refer to the "Network Server security" and "Running the Network Server under the security manager" sections of the Java DB Server and Administration Guide for important information on securing the Network Server and enabling network connections.
With the Network Server started, you can run the client program simultaneously in multiple windows. To demonstrate this, open two command windows and perform the substeps of the "Run the client program" step in each window. Both clients will operate without a problem. In contrast, it would not be possible for a program that uses the embedded driver (for example, WwdEmbedded.java) to access the database until the database or the Network Server is shut down.
You may have noticed that the client program does not shut down the database. This is because the database is a shared resource in a client/server environment and, in most cases, should be shut down only when the Network Server is shut down. If multiple clients are accessing the database and one client shuts down the database, the remaining clients will encounter a failure the next time they attempt an SQL command.
Derby's two architectures have caused confusion for some new Derby users, who mistakenly think that embedded is a single-user configuration. This is not true. The embedded driver supports multiple simultaneous connections, performs locking, and provides performance, integrity, and recoverability. Any application that uses the embedded driver can open multiple Derby connections and then provide a means for multiple users to interact with the database on each connection. The Derby Network Server is an example of such an application.