Assignment 13: JDBC

In this assignment, you will write a Swing application that will query a database. The database that you will query is running on dblab.cs.fiu.edu. You will not need to do any local setup to access this database, with the exception of downloading a database driver and making sure that it is on your classpath. You may work on this assignments in groups of two or three.

The name of the database is document. It contains the following columns: url, title, description, keywords, pagetext, outlinks, lastmodified, indexed, and brokered.

Setup Steps

  1. Download mysql.jar, which contains an SQL driver for the database. The file size is 71,328.
  2. Either update your CLASSPATH to include this jar file or extract the contents of the jar file to your working directory.
  3. The following program DBCommandLine.java connects to the database and repeatedly prompts for SQL commands (until QUIT is typed). Compile the program.
  4. You should be able to run the program with several commands. Here are some examples:

The Assignment

The assignment is to write a Swing application. In the Swing application, you should have a nice user interface. Here are some of the requirements:
  1. User should be able to select a lower and or upper limit for the number of outlinks. Do this with two textfields.
  2. User should be able to search for a pattern in the title.
  3. User should be able to search for a pattern in the keywords.
  4. User should be able to specify which of the nine columns are output (via nine separate checkboxes, or a checkbox that sets all).
  5. User should be able to set a limit on the number of rows that are returned.
  6. User should be able to specify one column (that must be one of the output columns) on which to sort, and may specify either increasing or decreasing.
  7. There should be two buttons. One is a submit button, and one is an abort button.
When the submit button is pressed, an appropriate actionPerformed is called that examines the input elements and forms a query. The query should be made in a separate thread, whose run method synchronizes to ensure only one executeQuery is performed at a time, and thus the actionPerformed method returning immediately. When the thread that is processing the request returns, it can update a JTextArea with the results. The abort button should stop all threads that are processing queries (of course only one is actually making a database connection). If you are doing this correctly, then a command such as SELECT * FROM document can be aborted. (A message can be printed if the ThreadDeath is caught.) You may use the deprecated stop method.

What to Submit

Submit your source code, sample output, and a floppy. In your submission, you must include a statement that details who did what and how much time each participant spent on the project. Your statement should be roughly equivalent to what you would use to justify consulting invoices to a client.