JAVA 6: JDBC AND DATABASE APPLICATIONS by POUL KLAUSEN

JAVA 6: JDBC AND DATABASE APPLICATIONS by POUL KLAUSEN

Author:POUL KLAUSEN [KLAUSEN , POUL]
Language: eng
Format: azw3, epub
Publisher: UNKNOWN
Published: 2021-01-12T16:00:00+00:00


After the prototype is finished, I’ve created a copy of the project, which I have called World0 . I will now continue to work on the project, but with the copy I can always return to the prototype.

102102 THE DATA MODEL As a next step I have written some model classes, and thus the classes to represent the program’s data.

There’s added three very simple model classes, representing respectively a continent, a country and currency: - Continent

- Country

- Currency

The classes are directly modeling the rows in the corresponding database tables, however, the class Currency extends with a list containing Country objects for the countries using this currency.

There are also defined a collection for each of the above types: - Continents

- Countries

- Currencies

. each of which includes an object for each row in the corresponding database table. Here the first of the classes is trivial, while the other two are reprogrammings of the corresponding classes from the prototype. The two classes are thus at the same time model for the program’s JTable components.

The total model is represented by the class DataModel, which is a simple class that is made up of an object by each of the above three collections. The program’s model can be illustrated as follows:

The three collections must be initialized, which is done by reading the corresponding database tables. To this end, it is written a class Repository, which only has static methods, including among others, methods that creates the three collection classes. The class Repository also has update methods for the tables currency and country, and that means that everything that has to do with the database is collected in this class. If the application must use a different database, it means that only this class has to be changed. The class Repository is a relatively complex class, as everything concerning the database and SQL are gathered here, and thus everything that is introduced in this book.

THE USER INTERFACE

The program’s user interface consists besides MainView of

- CurrencyView which is a dialog box for maintenance of currencies

- CountryView which is a dialog box for maintaining the countries Furthermore, there is a secondary dialog box called ErrorView and is used to display a list of errors with the import of exchange rates. Below is the MainView, which is the same view as in the prototype, but this time initialized with data:

For each view (except ErrorView) there is attached a controller. The goal is that the controller class should validate the user input and choices, and it is also, where appropriate the controller classes that calls the methods in the class Repository to update the model. The controller classes for the two dialog boxes for maintaining respectively currencies and countries works in principle the same. Below is the dialog for maintaining currency:

It is the same dialog that is used regardless of whether to create a new currency, or to edit an existing currency. In this case, there is double clicked EUR, in the main window.

Similarly is below shown the dialog box



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.