Servers, Servlets, and Applets
Page 2 of 4

JDBC Servers

As you learned in Cloudscape's Server Frameworks, only one application can access Cloudscape at a time if Cloudscape is embedded in an application. If you embed Cloudscape in special server framework software, multiple applications can connect to the same database at the same time. These applications connect over the network.

A JDBC server allows applications to execute JDBC calls remotely against a remote JDBC driver.

In this section, you start up RmiJdbc, a lightweight server framework included with the product, then run two client applications.

Start RmiJdbc Server

  1. Open a command window, and change directories to your_tutorial_home directory.
  2. Run the classPathScript.
  3. Add one more library to class path, %CLOUDSCAPE_INSTALL%/frameworks/RmiJdbc/classes/RmiJdbc.jar

    On a Windows platform, you would do that like this:

    SET CLASSPATH=%CLOUDSCAPE_INSTALL%\frameworks\RmiJdbc\classes\
    RmiJdbc.jar;%CLASSPATH%

  4. Use a Cloudscape utility that tests your class path for a particular environment. You will use it with the arguments RmiServer, to test for an RmiJdbc server environment, and sampleApp, to test for the sample application libraries.

    java COM.cloudscape.tools.sysinfo -cp RmiServer sampleApp

    The utility displays a message indicating success or failure. If you got a failure message, check your class path carefully.

  5. Start the server with the following command, being sure to set the value of cloudscape.system.home to the location of the directory that contains toursDB:

    java -ms32M
        -mx32M -Dcloudscape.system.home=
    your_tutorial_system
        RmiJdbc.RJJdbcServer COM.cloudscape.core.JDBCDriver

    You should get a startup message that looks something like this:

    Thu Sep 23 13:20:34 PDT 1999: [RmiJdbc] COM.cloudscape.core.JDBCDriver registered in DriverManager

    Thu Sep 23 13:20:34 PDT 1999: [RmiJdbc] Binding RmiJdbcServer...

    Thu Sep 23 13:20:34 PDT 1999: [RmiJdbc] No installation of RMI Security Manager...

    Thu Sep 23 13:20:35 PDT 1999: [RmiJdbc] RmiJdbcServer bound in rmi registry

    The RmiJdbc server is now started.

Run ij as a Client Application

  1. Open a command window, and change directories to your_tutorial_home directory.
  2. Run the classPathScript.
  3. Add two more libraries to class path, client.jar and %CLOUDSCAPE_INSTALL%/frameworks/RmiJdbc/classes/RmiJdbc.jar

    On a Windows platform, you would do that like this:

    SET CLASSPATH=%CLOUDSCAPE_INSTALL%\lib\client.jar;
    %CLOUDSCAPE_INSTALL%\frameworks\RmiJdbc\classes\RmiJdbc.jar;%CLASSPATH%

  4. Use a Cloudscape utility that tests your class path for a particular environment. You will use it with the arguments RmiClient, to test for an RmiJdbc client environment, and sampleApp, to test for the sample application libraries.

    java COM.cloudscape.tools.sysinfo -cp RmiClient sampleApp

    The utility displays a message indicating success or failure. If you got a failure message, check your class path carefully.

  5. Start ij:

    java COM.cloudscape.tools.ij

  6. Connect to toursDB using the correct client database connection URL. To do that, use the protocol jdbc:cloudscape:rmi: followed by the host name (localhost) and port number (1099 is the default).

    Connect 'jdbc:cloudscape:rmi://localhost:1099/toursDB';

    Keep the connection open for now.

Open a Client Window, and Run an Application

The JBMSTours applications also allow you to run them as a client to RmiJdbc.

  1. Open another command window, and change directories to your_tutorial_home directory.
  2. Set the class path for an RmiJdbc client environment as described in Run ij as a Client Application.
  3. Run the classPathScript.
  4. Try running JBMSTours.Generate Report as a client application. Do do that, you need to add three arguments:
    • the host name
    • the port number
    • the letter "r" if the server framework is RmiJdbc.

      Since you are running the server framework locally and are using the default port numbers, the host name is localhost and the port number is 1099.

      That means you can run the application like this:

      java JBMSTours.GenerateReport localhost 1099 r

      Note that you do not need to set the location of cloudscape.system.home. You do that on the server only.

  5. While the application is running, go back to the first client window.
  6. Execute the following SQL-J statement:

    SELECT * FROM Locks WHERE TableName NOT LIKE 'SYS%';

  7. If you have time, execute it again. Notice that you can see the locks held by the other application.
  8. Exit ij:

    exit;

  9. From the same client window, stop the server like this:

    java RJPing jdbc:rmi:jdbc:cloudscape: shutdown

  10. Close all windows.