Data Management and Export Tools Overview

Jul 14, 2024

Introduction to Data Management and Export Tools

Key Points

  • The data entry phase is now complete, and we need to extract, analyze, and filter the data.
  • Export to Excel is a vital feature that makes it easy to export and print data in Excel.

Model-View-Controller (MVC)

  • Model: A class or object also known as a Bean Class. It contains properties and their getters/setters.
  • Views: UI components to display data.
  • Controller: Handles business logic and coordinates between the model and views.

Bean Class

  • POJO Class: Plain Old Java Object, a regular Java class.
  • A Bean Class has properties, getters, and setters.
  • Bean classes are used in many techniques of Spring Boot and Java.

Data Transfer

  • A Table View cannot be directly linked to a database; data must first be loaded into memory.
  • Data is managed as an Array of Objects.

Export to Excel

  • An Array of Objects is used to export table data to Excel.
  • Create a function to write data to Excel and loop through the data, writing it to an Excel file.

Code Snippets

  • Data Loading and Fetching:
    PreparedStatement ps = connection.prepareStatement("SELECT * FROM table");
    ResultSet rs = ps.executeQuery();
    while (rs.next()) {
      // Load each row into an object and add to list
    }
    
  • Export to Excel Code:
    FileWriter excel = new FileWriter("output.xlsx");
    for (Object obj : arrayOfObjects) {
      excel.write(obj.toString());
    }
    excel.close();
    

Other Important Points

  • Map the subject with bound columns.
  • Add columns to the Table View at runtime.
  • Parameterization is essential in constructors and getters/setters.
  • Use a default constructor.

Assignment

  • Create a form that includes information on workers and customers.
  • Use specialization to filter workers.
  • Practice loading data from the database and displaying it in a Table View.