You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following is an example of using all the methods of this class in Java.
// User classDBTransactiontx = newDBTransaction();
if (tx.registerUser("admin", "1234567p")) System.out.println("Signed up"); // register new user; return true or falseelseSystem.out.println("This login is existing in db");
tx.printUsers(0); // show all users (id, login, password) // userId=0 to show all users, type specified userId to get one user with this IDtx.ifUserExist("usr2"); // check if user exists; return true if user exists and return false if not foundif (tx.signIn("usr1", "qwerty")) { // sign in method; return true or falseSystem.out.println("Signed in");
} else {
System.out.println("Incorrect pass");
}
tx.changePassword(1, "wasd000"); // change user's password; user is searched for by his id; return true or false//Student classtx.addStudent("Kowalski", "Jan", "4c", "2022/2023"); // add student to the db; return true or falsetx.printStudents(); // show all students (id, name, surname, studentGroup, schoolYear)List<Student> y = tx.getStudents_byId(2); // return list of students by specified id; put 0 to get all studentsfor (Students : y){
System.out.println(s.getName());
}
tx.getStudents_byName("Jan"); // return list of students by nametx.getStudents_bySurname("Nowak"); // return list of students by surnametx.getStudents_byGroup("4c"); // return list of students by students' grouptx.getStudents_bySchoolYear("2022/2023"); // return list of students by school yeartx.editStudent(2,"Nowakowska", "Anna", "3e", "2022/2023"); // edit student in db; return true or falsetx.deleteStudent(1); // delete student by id with all his grades//Grade classtx.addGrade(5, "math", "exam", "", 2, 1); // add grade to the db; return true or falsetx.editGrade(1, 4.5, "math", "exam", "corrected", 2, 1); // edit grade in db; return true or falsetx.deleteGrade(2); // delete grade by gradeId; return true or falsetx.getGrades_byId(1); // return list of grades by gradeIdtx.getGrades_byId_withStudentName(1); // return list of pairs grades and students by gradeId// WARNING: all below getGrades_ methods return results for specified school year (school year must be in format "0000/0000")tx.getGrades_byStudentId(1, "2022/2023"); // return list of grades by studentIdtx.getGrades_byUserId(1, "2022/2023"); // return list of grades by userIdtx.getGrades_bySubject("math", "2022/2023"); // return list of grades by subjecttx.getGrades_byStudentGroup_nSubject("math", "4c", "2022/2023"); // return list of grades by subject and students' group