@Override public StudentModel getStudentId(StudentModel studentModel) { // TODO Auto-generated method stub /* * this is the foreign key in progarmsstudents table. */ ResultSet myRes = null; try { Class.forName("com.mysql.jdbc.Driver"); Connection myCon = DriverManager.getConnection("jdbc:mysql://localhost:3306/EnrollTrackDB", "root", ""); Statement myStmt = myCon.createStatement(); myRes = myStmt.executeQuery( "SELECT * from studentInformation where studentEmail='" + studentModel.getStudentEmailID() + "'"); while (myRes.next()) { studentModel.setStudentID(Integer.parseInt(myRes.getString("studentID"))); } } catch (Exception e) { e.printStackTrace(); } return studentModel; }
@Override public void update(StudentModel studentModel) { // TODO Auto-generated method stub try { Class.forName("com.mysql.jdbc.Driver"); Connection myCon = DriverManager.getConnection("jdbc:mysql://localhost:3306/EnrollTrackDB", "root", ""); Statement myStmt = myCon.createStatement(); myStmt.executeUpdate( "UPDATE studentInformation set `currentGPA`=' " + studentModel.getCurrentGPA() + "',`studentDOB`='" + studentModel.getDOB() + "',`studentCellNumber`='" + studentModel.getCellNumber() + "',`studentHomePhone`='" + studentModel.getHomePhone() + "',`Ethnicity_ethnicityId`='" + studentModel.getEthnticity() + "',`School_schoolId`='" + studentModel.getCurrentSchool() + "',`Gender_genderId`='" + studentModel.getGender() + "'," + "`CurrentGrade_currentGradeId`='" + studentModel.getCurrentGrade() + "' WHERE `studentEmail`=" + "'" + studentModel.getStudentEmailID() + "'"); } catch (Exception e) { e.printStackTrace(); } }
@Override public void insert(StudentModel studentModel) { // TODO Auto-generated method stub ResultSet myRes = null; int id = 0; try { Class.forName("com.mysql.jdbc.Driver"); Connection myCon = DriverManager.getConnection("jdbc:mysql://localhost:3306/EnrollTrackDB", "root", ""); Statement myStmt = myCon.createStatement(); myRes = myStmt.executeQuery( "SELECT * from Authentication where userName='******'"); while (myRes.next()) { id = myRes.getInt("authenticationID"); } myStmt.executeUpdate( "INSERT INTO studentInformation (`studentFirstName`, " + "`studentLastName`,`studentMiddleInitial`,`studentEmail`,`Authentication_authenticationID`) " + "VALUES ('" + studentModel.getFirstName() + "', '" + studentModel.getLastName() + "', '" + studentModel.getMiddileInitial() + "', '" + studentModel.getStudentEmailID() + "', '" + id + "')"); } catch (Exception e) { e.printStackTrace(); } }
@Override public void insertAddressID(StudentModel studentModel) { // TODO Auto-generated method stub try { Class.forName("com.mysql.jdbc.Driver"); Connection myCon = DriverManager.getConnection("jdbc:mysql://localhost:3306/EnrollTrackDB", "root", ""); Statement myStmt = myCon.createStatement(); myStmt.executeUpdate( "UPDATE studentInformation set `Address_addressId`=' " + studentModel.addressModel.getAddressID() + "' WHERE `studentEmail`=" + "'" + studentModel.getStudentEmailID() + "'"); } catch (Exception e) { e.printStackTrace(); } }
@Override public StudentModel getDOB(AuthenticationModel authenticationModel) { // TODO Auto-generated method stub StudentModel studentModel = new StudentModel(); studentModel.setStudentEmailID(authenticationModel.getUserName()); ResultSet myRes = null; try { Class.forName("com.mysql.jdbc.Driver"); Connection myCon = DriverManager.getConnection("jdbc:mysql://localhost:3306/EnrollTrackDB", "root", ""); Statement myStmt = myCon.createStatement(); myRes = myStmt.executeQuery( "SELECT `studentDOB` from studentInformation where studentEmail='" + studentModel.getStudentEmailID() + "'"); while (myRes.next()) { studentModel.setDOB(myRes.getString("studentDOB")); } } catch (Exception e) { e.printStackTrace(); } return studentModel; }