CPS616
Assignment #3 - RMI - JDBC Oracle
Christian Sarmoria


You can see the client applet in Client.java , the server side application in Server.java , the remote methods implementation in DBCRemote.java and the database class in myDatabase.java


Note: This RMI application was tested using Netscape Communicator version 4.5 or later. Even when you may be able to see the applet in your screen, the ORACLE database may or may not be accessible if your browser is not Netscape 4.5 or later version.


All files related with this assignment are stored in the following path: /servers/cgi-http-class/htdoc/cps616spring99-docs/cy99cps/docs/assign3 except for the database files which are in the Oracle server.


My Solution:

This application is intended to manage Oracle database files through the WEB using Java, JDBC and Remote Method Invocation (RMI). This is a three-tier application model developed as a sample to manage a planes database. As you will see in the white central panel of the application, there are 6 different fields (filled in white color). Each of them represents the following data:


Code: the code of the plane.

Name: the name of the plane.

Released: the year when the plane was first released.

Made in: the country where the planes has its origin.

Picture: is the name of the file containing the picture of the current plane.

Base price: the base price of the plane, without special equipment.

Equip: a code for the equipment type: relates this record to the corresponding in the EQUIPMENT table.

Gun machine: the number of gun machines the plane has.

Missile: the number of missiles it can load.

Special Equipment: if has some special weapons.

Days to build: how many days it takes to build and deliver the plane.


Sample input you can try:

Code: 132

Name: NightFlyer

Released: 1989

Made in: France

Picture: night_f.gif

Base price: 16000000

Equip: 9

Gun machine: no data here, it is already stored in the EQUIPMENT table

Missile: no data here, it is already stored in the EQUIPMENT table

Special Equipment: no data here, it is already stored in the EQUIPMENT table

Days to build: no data here, it is already stored in the EQUIPMENT table



... and press the "Add Record" button to store this record.


Then you may try to run a search by writing NightFlyer or Nigh or any left side of the plane's name in the "Enter Plane name:" green field at the bottom of the applet. Then press the "Search" button and the record will be retrieved.

To make it clear, enter some more planes and search them in the same way.

The applet will allow you to search using string matching, add and delete records into the ORACLE database. To know all the necessary details about how to use this application, you can read the "How to use" section below in this form.


How to use:

All this explanations are assuming that you are using the browser already pointed and the connection with the ORACLE database is established.

At any time the gray field located in the white central panel will give you messages if something goes wrong with the records retrieval.

The first thing you have to do is establish a connection with the Oracle server. This can be done by clicking the "Connect" button located in the applet. After the connection is performed, you may then choose any of the following actions:

Search for a record in the database: just fill the plane name (or its first letters) in the "Enter Plane name to search" green field and then press the "Search" button on its right side. If record/s are returned, the first will be shown in the white central panel. If the query returns more than one record (in case your search was with the first letters and therefore left-matching is used) you can go through all of them by clicking the "Next" button on the right panel.

Go through all the records in the database: this can be done by clicking the "Search" button when the "Enter country name to search" field is empty. Then all records are retrieved and you can read each of them by clicking the "Next" button in the applet.

Add a record into the database: you can do this by filling the fields in the white central panel (see above which fields need to be filled) and then click on the "Add Record" button located in the right panel. The record will be added.

Delete a record from the database: you can write the name of the plane in the "Name" field (white central panel) you want to erase and then click on the "Delete Record" button located in the right side of the applet. The record (if the plane actually exists in the DB) will be deleted. It may be easier to search for a plane and then, when it is shown in the white panel, you can just click the "Delete Record" button to erase that record.

Close the connection: click on the "Close" button on the left side of the applet and the connection with the ORACLE server will be terminated.


Database design:

Two tables are used by this applet: PLANES and EQUIPMENT

(Recall that the information stored in the database is far from accurate: data store there is sample data).

Table PLANES:


CODE NUMBER(4) primary key

NAME VARCHAR2(30) not null

RELEASED NUMBER(4) not null

MADEIN VARCHAR2(30) not null

PICTURE VARCHAR2(15) not null

BASEPRICE NUMBER(9) not null


EQUIP NUMBER(2) not null
Table EQUIPMENT:



CODE_EQU NUMBER(4)

GUNMACHINE_EQU NUMBER(1)

MISSILE_EQU NUMBER(2)

SPECIAL_EQU VARCHAR2(1)


DAYS_TO_BUILD NUMBER (4)
   



The fields that relate both tables when doing the queries are "equip" from table PLANES and "code_equ" from table EQUIPMENT.

Relation is: one-to-many (one equipment record may relate to many planes records).

VERY IMPORTANT: The table Equipment is aready set up with all the possible setups the planes may have. When you add a new plane, be sure to write a number between 1 and 12 in the "Equipment Code" field in the white central panel. This will relate your plane record to an equipment record.

You can see the SQL scripts I used to create the Oracle database tables in assign3create.sql and the script file to add records in assign3add.sql


The Flow of Control:

assign3.gif


Go back to the assignments main page


cgsarmor@mailbox.syr.edu