Skip to content

Persistence

Cathrine Kristiansen edited this page Apr 14, 2026 · 1 revision

Persistence

Persistence shows how the application retrieves and stores data, and whether the information is lost when the program terminates. In this application, both database and external data sources are used to handle data.

When handling data the application uses these technologies:

  • MySQL: main solution for storing data (users and donations).
  • DAO (Data Access Objects): structured access to the database.
  • JSON/API: used to retrieve external data about charities.
  • FXML: used for user interfaces (are therefore not persistence).

Most of the system storage takes place in the database. Here we can find stored data types such as users and donations. Connections are handled in DatabaseConnection.java, where connections to the MySQL database are established via JDBC. In order to maintain and separate code connected to the database from the rest of the system, the DAO pattern is used. User data and donations are handled in UserDAO.java and DonationDAO.java. In addition, separate "Reader" classes are used to retrieve data, such as UserSelect, DonationSelect and CharitySelect.

Data flows through the system in the following way:

  • User interacts with GUI (FXML)
  • Controller receives input
  • Controller calls DAO/methods
  • Data is stored in the database
  • On startup or display, data is retrieved from the database and displayed in the GUI

To retrieve data from external APIs, JSON is used in the application, especially for charities such as APICharityScraper, APICharityData, FullCharityScraper. The JSON data is then retrieved from the API, converted to Java objects and used in the application. However, it is not necessarily stored permanently.

FXML is used to define the user interface and connects to controllers. Although FXML does not store data, it is important for displaying data retrieved from the database and allowing the user to create and modify data.

This solution has clear advantages such as good code structure with DAO pattern, and MySQL contributes to a stable and scalable solution. Although the solution creates good separation between GUI, logic and database, the API integration also provides dynamic content. Therefore, it is clear that the system has many advantages, but at the same time the application also has some challenges. This can be seen when it comes to database setup and connections to the local database, which is connected to the school's network. It is also sometimes challenging to separate JSON data and actual persistence, since not all data is actually stored. There is still potential for improvement when handling credentials and with some more error handling.

Whit this, the application uses a database-based solution for persistence, supported by the DAO pattern. External data is retrieved via API and JSON, while FXML handles data presentation. Together, this provides a structured and functional solution.

Clone this wiki locally