
Servers and Servlets,
Page 2 of 3
|

|

[top]  [prev]
  [next]
Road Map
Glossary
 Index for This Book
Documentation Top
Global Index
|
JDBC Servers
As you learned in Cloudscapes 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.
TASK: Start RmiJdbc Server
Open a command window, and change directories to your_tutorial_home directory.
Run the classPathScript.
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\RmiJd
bc.jar;%CLASSPATH%
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.
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.
TASK: Run ij as a Client Application
Open a command window, and change directories to your_tutorial_home directory.
Run the classPathScript.
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_INSTA
LL%\frameworks\RmiJdbc\classes\RmiJdbc.jar;%CLASSPATH%
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 server 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.
Start ij:
java COM.cloudscape.tools.ij
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.
TASK: Open a Client Window, and Run an Application
The JBMSTours applications also allow you to run them as a client to RmiJdbc.
Open another command window, and change directories to your_tutorial_home directory.
Set the class path for an RmiJdbc client environment as described in Run ij as a Client Application.
Run the classPathScript.
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.
While the application is running, go back to the first client window.
Execute the following SQL-J statement:
SELECT * FROM Locks WHERE TableName NOT LIKE 'SYS%';
If you have time, execute it again. Notice that you can see the locks held by the other application.
Exit ij:
exit;
From the same client window, stop the server like this:
java RJPing jdbc:rmi:jdbc:cloudscape: shutdown
Close all windows.
|