SimpleDB Help

About the applet

Purpose

SimpleDB is a very basic data applet. It reads tab-delimited data from a URL, and generates a form on the fly to read and edit the data.

Author

This applet was written by Andy Harris for the book "Java Fast and Easy".

Setting up the database

The data file

The first row of the data file must contain field names seperated by tab characters. Each row of the file must be the field values separated by tabs. The last row must be blank. Most spreadsheets and database packages allow you to save to a tab-delimited format. The data file must be stored in the same directory as the HTML file which contains the applet. The current version of the applet allows a maximum of 100 records, but this is easily changed in the java source code.

The HTML

Write an HTML file to use the applet with all the normal applet tag information. Add a param tag with the appropriate datafile, like this:
  <applet code = SimpleDB
          height = 400
	  width = 600>
  <param name = "DataFile"
         value = "grades.dat">
  </applet>
  
If the file name is incorrect, the applet will pop up a warning message.

The commands

Prev

Calls up the previous record in the database. If you are currently on the first record, this command will 'wrap around' and show the last element.

Next

Calls up the next record in the database. If you are currently on the last record, this command will 'wrap around' and show the first element.

Copy

Because of security restrictions, Java applets normally cannot save information to a disk drive. SimpleDB allows you to copy the current database to the system clipboard so you can paste it into a text editor and change the data. This acts like a security feature, as anyone who can access the data can modify their own copy of the data, but only the person with access to the datafile can change it. To use this feature, select the entire text area with the mouse, and use the mouse menu (right click or click and hold on most systems) to copy the data to the system clipboard. You can then paste the data into a text editor, and save it to the data file. Don't forget that the last line of your data file should be empty.

Search

This command requests a word or phrase to search for. It searches through the data and displays each record that contains the data. The search mechanism is case-sensitive.

Add

The add command adds a new record to the database. It then displays the new record. Remember that this applet cannot directly save the data. You need to use the copy feature to copy the data to your text editor if you want the changes to be permanent.

Editing Data

The user can edit the current record by just changing the values in the fields. Remember that this applet cannot directly save the data. You need to use the copy feature to copy the data to your text editor if you want the changes to be permanent.