public static Lesson getLessonById(int id) {

    Lesson result = null;

    String sql =
        "SELECT * FROM " + Schedules.TABLE + " WHERE " + Schedules.ID_LESSON + '=' + id + ';';
    try {
      ResultSet rs = statement.executeQuery(sql);

      if (rs.next()) {
        result =
            new Lesson.Builder()
                .idLesson(rs.getInt(Schedules.ID_LESSON))
                .day(DateTimeConverter.parseDayOfWeek(rs.getInt(Schedules.ID_DAY)))
                .group(getGroupOverviewById(rs.getInt(Schedules.ID_GROUP)))
                .order(rs.getInt(Schedules.ORDER))
                .subject(getSubjectOverviewById(rs.getInt(Schedules.ID_SUBJECT)))
                .teacher(getTeacherOverviewById(rs.getInt(Schedules.ID_TEACHER)))
                .classroom(rs.getString(Schedules.CLASSROOM))
                .build();
      }

    } catch (SQLException e) {
      logger.log(Level.SEVERE, "Error getting lesson by id", e);
    }

    return result;
  }
  public static StudentSchedule getStudentScheduleById(int id) {

    StudentSchedule result = new StudentSchedule(getGroupOverviewById(id));

    String sql =
        "SELECT %1, %2 ,%3, %4, %5, %6 "
            + " FROM "
            + Schedules.TABLE
            + " WHERE "
            + Schedules.ID_GROUP
            + '='
            + result.getGroup().getId()
            + ';';
    sql = sql.replace("%1", Schedules.ID_LESSON);
    sql = sql.replace("%2", Schedules.ID_SUBJECT);
    sql = sql.replace("%3", Schedules.ID_DAY);
    sql = sql.replace("%4", Schedules.CLASSROOM);
    sql = sql.replace("%5", Schedules.ID_TEACHER);
    sql = sql.replace("%6", Schedules.ORDER);

    try {
      ResultSet rs = connection.createStatement().executeQuery(sql);

      while (rs.next()) {

        StudentLesson added =
            new StudentLesson.Builder()
                .idLesson(rs.getInt(Schedules.ID_LESSON))
                .subject(getSubjectOverviewById(rs.getInt(Schedules.ID_SUBJECT)))
                .day(DateTimeConverter.parseDayOfWeek(rs.getInt(Schedules.ID_DAY)))
                .classroom(rs.getString(Schedules.CLASSROOM))
                .order(rs.getInt(Schedules.ORDER))
                .teacher(getTeacherOverviewById(rs.getInt(Schedules.ID_TEACHER)))
                .build();

        result.addLesson(added);
      }

    } catch (SQLException e) {
      logger.log(Level.SEVERE, "Error getting student schedule", e);
    }

    return result;
  }
  public static void refreshAdminData(int id) {

    Runnable r =
        () -> {
          String sql =
              "UPDATE "
                  + Admins.TABLE
                  + " SET "
                  + Admins.LAST_SEEN
                  + "='"
                  + DateTimeConverter.format(LocalDate.now())
                  + "' WHERE "
                  + Admins.ID_ADMIN
                  + '='
                  + id
                  + ';';
          try {
            statement.executeUpdate(sql);
          } catch (SQLException e) {
            logger.log(Level.SEVERE, "Error updating admin last seen", e);
          }
        };
    r.run();
  }