CISC 322 Persistent Dictionary

From EQUIS Lab Wiki

Jump to: navigation, search

The persistent dictionary class provides simple access to a database. A persistent dictionary provides a dictionary datastructure that is represented in a database, and therefore is persistent. If you add elements to a dictionary in one run of your program, the elements will still be in the dictionary the next time you run the program.

  • The persistent dictionary class is documented here.
  • You can obtain the code for the persistent dictionary via a link provided on the WebCT forum.

Contents

Using the Persistent Dictionary

There are three steps to using the persistent dictionary in a project:

  • Download and install the MySQL JDBC connector
  • Configure your project to use the MySQL JDBC connector
  • Download the persistent dictionary code and load it into your Eclipse project

Downloading the MySQL JDBC Connector for Use at Home

The MySQL JDBC connector is required to run the persistent dictionary. It is already installed in the CASLAB, at C:\mysql-connector-java-5.0.7-bin.jar.

To run the persistent dictionary on your home computer, you need to download and install the MySQL JDBC connector. Follow these instructions:

  • Download the latest version of Connector/J, the JDBC connector, here. (At time of writing, the latest production version is 5.0.)
  • Extract the downloaded archive.
  • The JDBC connector is contained in a file named something like mysql-connector-java-5.0.7-bin.jar. Place this file in the location of your choice (e.g., C:\mysql-connector-java-5.0.7-bin.jar).

Configuring Your Project to Use Connector/J

To use Connector/J in a project, you need to add it into the project's Java Build Path.

  • Open your project's property sheet: Right click on the project name in the package explorer, and select Properties.
  • Select Java Build Path, and select the Libraries tab.
  • Click Add External JARs.... Browse to the location where you saved the Connector/J jar file (e.g., C:\mysql-connector-java-3.1.10\mysql-connector-java-3.1.10-bin.jar) and follow the dialogue to add it to your project.
  • Click Ok to exit the properties dialogue.

Adding the Persistent Dictionary to your Project

  • Download and extract the persistent dictionary code. (See the WebCT forum for its location.)
  • Import the persistent dictionary using Eclipse's Import dialogue:
    • Select File|Import
    • Select File System as the import source
    • Browse to the location where you extracted the Persistent Dictionary source code.