The toursDB sample database is the foundation for most of the examples in the Cloudscape documentation. This database comes prebuilt in your installation under /demo/databases. Getting Started with Cloudscape offers instructions on the simplest way to connect to this database with Cloudscape's GUI tool, Cloudview.
This database also comes with a sample application, called JBMSTours, which you can run to see how a simple application interacts with the database. For example, the class CreateToursDB in the application builds the database. It creates the schema and inserts data into the database. The application includes other classes that you will want to look at.
You can also build the database using one of the main entry points in the application. Learning Cloudscape: The Tutorial takes you through all the steps of building and using the application and the sample database.
NOTE: This database and the accompanying application make heavy use of Cloudscape's object-relational features in order to show you how to use them. In practice, your database would probably make much greater use of the standard SQL-92 data types.
In addition, the javadoc for the package provides basic information for using the application.
Full information on working with the database and the application is provided in Learning Cloudscape: The Tutorial. These instructions provide a quick "cheat sheet."
Before you begin, determine which environment you want to run in:
In an embedded environment, an application starts up an instance of Cloudscape.
To run any of the applications in an embedded environment, or to access any of the object data in the database, the following libraries must be in your class path:
For users not working with Cloudscape synchronization, the main Cloudscape library is called cloudscape.jar and is found in the %CLOUDSCAPE_INSTALL%/lib directory. These users would set the class path as follows (Windows):
%CLOUDSCAPE_INSTALL%/lib/cloudscape.jar;
%CLOUDSCAPE_INSTALL%/demo/programs/tours;
For users who are working with Cloudscape synchronization, the main Cloudscape library is called cloudsync.jar. It is found in the %CLOUDSCAPE_INSTALL%/lib directory.
If you want to just build the database and run all the main programs in the application, run them in this order:
Helps you create an SQL script you can use to rebuild a clean database. You will have to redirect the output of the program to a file. See the javadoc for JBMSTours.CreateScript for more information.
Shows you how to perform some administrative tasks such as backing up a database, running the consistency checker, turning on user authentication, and the like.
Or you could run all but the first one against the pre-built version. The easiest way to do that would be to run all the applications from the %CLOUDSCAPE_INSTALL%/demo/databases directory.
In a client/server environment, Cloudscape is already running inside a server framework. Multiple client application simply connect to it. |
You can also run any of the applications with main methods as client applications that connect to Cloudscape running inside a connectivity (server) framework. This application supports the following frameworks:
For quick-start information on starting one of these frameworks, see the simple demo. Follow those instructions, with the following addition: Before starting the server, add %CLOUDSCAPE_INSTALL%/demo/programs/tours to the class path.
To run any of the applications in a client environment, or to access any of the object data in the database, the following libraries must be in your class path:
For example, you would set the class path to the following (Windows):
%CLOUDSCAPE_INSTALL%/lib/client.jar;
%CLOUDSCAPE_INSTALL%/frameworks/cloudconnect/classes;
%CLOUDSCAPE_INSTALL%/frameworks/cloudconnect/lib/weblogicaux.jar;
%CLOUDSCAPE_INSTALL%/frameworks/cloudconnect/license;
%CLOUDSCAPE_INSTALL%/demo/programs/tours;
You can run the same applications as you would in embedded environment (see Embedded Environment). To run the applications as client applications, you must provide two or three arguments when invoking them:
For example, to run JBMSTours.CreateToursDB in a client environment when your framework is Cloudconnector, which is running on your own machine in the default port, you would type:
java JBMSTours.CreateToursDB localhost 7001
To run JBMSTours.CreateToursDB in client environment when your framework is RmiJdbc, which is running on your own machine in the default port, you would type:
java JBMSTours.CreateToursDB localhost 1099 r
Run the CreateToursDB application before running any of the others, so that you have a database to work with.
To run JBMSTours.AdminHelper with the argument back_up in the RmiJdbc framework, you would type:
java JBMSTours.AdminHelper localhost 1099 r back_up
The JBMSTours application provides examples of several different things you can do with an application using Cloudscape as a data manager. Here are some of the highlights:
The savvy user will want to get straight to the heart of the matter. Queries!
To use the tool ij, add %CLOUDSCAPE_INSTALL%/lib/tools.jar to your class path. Once you start ij, you can connect to toursDB like this:
Connect 'jdbc:cloudscape:toursDB';
Or, if you're in a client/server environment, like this:
Connect 'jdbc:cloudscape:weblogic:toursDB';
Try out some of these queries (from the tutorial):
SELECT * FROM Flights
WHERE orig_airport = 'JFK'
AND flying_time > 5;
SELECT Country, City FROM Countries JOIN Cities
USING (country_ISO_code);
SELECT Flights.flight_id, Flights.segment_number, flight_date,
economy_seats_taken, business_seats_taken,
firstclass_seats_taken
FROM Flights JOIN FlightAvailability
USING (flight_id, segment_number);
SELECT city.getName() AS CITY, hotel_name
AS HOTEL, booking_date, rooms_taken
FROM Cities, Hotels, HotelAvailability
WHERE Cities.city_id = Hotels.city_id
AND Hotels.hotel_id = HotelAvailability.hotel_id;
SELECT NEW JGroup(group_id, number_kids, number_adults, number_people, main_person, number_rooms, city_id, address, phone, tour_level, budget, running_total).toString(getCurrentConnection()) FROM Groups;
SELECT customized_tour.toString()
FROM CustomizedTours;
SELECT city->language FROM Cities;
SELECT city.getName(), city.getDistanceFrom(
(SELECT city FROM Cities WHERE city_id = 35))
AS MILES_FROM_PARIS FROM cities;
SELECT city.getName(),
city.getTimeDifference(getCurrentConnection(),
CURRENT_DATE, 'JFK')
AS CurrentTimeDifFromNewYork
FROM Cities
WHERE city_id = 35;
VALUES (findcity(GETCURRENTCONNECTION(),
'Amsterdam', 'Netherlands').toString());
VALUES (findcity(GETCURRENTCONNECTION(), 'AMS').toString());
CALL cleanOutFlightAvailability(GETCURRENTCONNECTION());
CREATE STATEMENT findRoomsTaken
AS SELECT rooms_taken
FROM HotelAvailability
WHERE hotel_id = ? AND booking_date = ?;
EXECUTE STATEMENT findRoomsTaken
USING VALUES (5, current_date);
VALUES FlightBuilder.
returnAnyFlight(getCurrentConnection() ,
'SFO','MAD').toString();
VALUES FlightBuilder.returnAnyFlight(
getCurrentConnection(), 'JFK','CAI').toString();
SELECT color, food
FROM
(VALUES ('orange', 'orange'), ('apple', 'red'),
('banana', 'yellow'))
AS Fruits_And_Colors(fruit, color)
JOIN
(VALUES ('orange', 'orange juice'), ('apple', 'pie'), ('apple', 'muffins'),('banana', 'bread'),
('banana', 'meringue pie'))
AS Fruits_And_Foods(fruit, food)
USING (fruit);
SELECT AVG(customized_tour.getTotalMilesTraveled())
FROM CustomizedTours;
SELECT MIN(miles)
FROM Flights
WHERE orig_airport = 'SFO';
SELECT MAX(city.showTemperature()), Region
FROM Cities JOIN Countries USING (country_ISO_code)
GROUP BY Region;
INSERT INTO people (person)
VALUES (NEW Person('Your', 'Name'));
SELECT (CAST (person AS Adult)).getPassportNumber()
FROM People
WHERE person INSTANCEOF Adult;
To see some pictures stored in the database, go straight to that section in the tutorial.
Cloudscape Version 3.6
For technical support, go to: www.informix.com and click Services.