next up previous
Next: 5. Part IV: Entity-Relationship Up: No Title Previous: 3. Part I: Simple

This part of the project is to be implemented individually.

4. Part II: Object storage using JDBC and MySQL

In this part of the project you will implement methods for objects that store and retrieve the object data using JDBC and the MySQL database.  In the previous part of the project, you used the Serializable interface to store Java objects to disk.  One of the significant limitations of this is that objects cannot be retrieved if changes are made to the class definitions.  Another problem is that stored data are opaque: they cannot be used or shared across other applications that do not use the same object class definitions.  Finally, storing objects as disk files is not a DBMS, there is no access control, concurrency control, recovery, etc.
  1. The SQL interface

  2. One way to address some of the problems with lightweight persistence is to use an SQL database to store objects.  This offers the advantages of using a relational  database (transparency, control, data sharing, etc.) while preserving the object model.  To do this, you will define a set of methods that will be implemented for every object that you will store in the database:

           throws NotInDBException Here is the example code and jar file:


    Do all of the following:

       
    1. For each of the object classes in the previous assignment (Customer and Database), implement the readSQL method to initialize the objects from values stored in a MySQL database.  Be sure that you correctly handle forward object references by keeping track of objects in a hashmap, and that you understand how to retrieve multi-valued attributes and relationships in SQL relations.
    2. For each of the object classes in the previous assignment (Customer and Database), implement the writeSQL method to save values from the objects in a MySQL database.  Be sure that you understand how to store multi-valued attributes and relationships into SQL relations.
    3. For each of the object classes in the previous assignment (Customer and Database), implement the removeSQL method to remove the persistent object data from the MySQL database.
    4. In your MySQL database, define all of the tables required for the methods above.  Manually insert the data from the previous assignment into these tables.
    5. Write a test program that creates and initializes all the objects in the database and then prints them out in a form that shows their values and relationships.  Then have the program add some new objects and delete some existing objects.
    6. Using the MySQL client, print out the contents of all of your database tables showing the changes.

 


Jack Keane

2002-28-02