Add updateAttendance()

This commit is contained in:
2022-06-09 13:03:54 +08:00
parent 743f3fd055
commit 08ec94b99a

View File

@@ -274,6 +274,19 @@ public class DatabaseHelper {
return courses;
}
public static boolean updateAttendance(String attID, AttStatus attStatus) throws NoConfigException, SQLException, DependenciesNotFoundException {
if (!isExistsInAttendance(attID)) throw new DependenciesNotFoundException();
String sql = "UPDATE attendance SET attStatus=? WHERE attID=?";
try (Connection connection = PoolHelper.getConnection()) {
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
preparedStatement.setString(1, attStatus.name());
preparedStatement.setString(2, attID);
return preparedStatement.executeUpdate() == 1;
}
}
}
public static void close() {
PoolHelper.close();
}