Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROC [dbo].[getStudentHistory]
- @studentId INT
- AS
- SELECT LastName, FirstName, Year, Term, C.Prefix + ' ' + CAST(C.Num AS CHAR(3)) + ' - ' + SEC.Letter AS [Course Number],
- Units, isNull(G.Letter, ' ') AS Grade
- FROM Student S
- INNER JOIN StudentInSection SIS
- ON S.StudentId = SIS.StudentId
- INNER JOIN Section SEC
- ON SEC.SectionId = SIS.SectionId
- INNER JOIN Course C
- ON C.CourseId = SEC.CourseId
- LEFT OUTER JOIN Grade G
- ON G.GradeId = SIS.GradeId
- INNER JOIN Semester SEM
- ON SEM.SemesterId = SEC.SemesterId
- WHERE S.StudentId = @studentId
- Order BY Units DESC
- @SuppressWarnings("resource")
- public static void showStudentHistory()
- {
- System.out.print("n Please enter the Id of a current student you wanna see grades for");
- System.out.print("n==>");
- Scanner insertstudentID = new Scanner(System.in);
- int passedStudentID = insertstudentID.nextInt() ;
- Student student = new Student(passedStudentID, null, null);
- List<Student> students = student.getStudentHistory(passedStudentID);
- String tabs = "tt";
- System.out.println("LastName"+ tabs + "FirstName"+ tabs + "Year"+ tabs + "Term"+ tabs + "Course Number"+ tabs + "Units"+ tabs + "Grade");
- System.out.println("---------"+ tabs + "---------"+ tabs + "--------"+ tabs + "-----------");
- // Student tempStu = students.get(passedStudentID);
- // System.out.println(tempStu.getmStudentId() + "ttt" +
- // padRight(tempStu.getmFirstName(), 15) + "tt" +
- // padRight(tempStu.getmLastName(), 15) + "tt" +
- // tempStu.getmNum());
- Scanner kb = new Scanner(System.in);
- System.out.print("nHit Enter to continue...");
- String discard = kb.nextLine();
- public List<Student> getStudentHistory(int StudentID) {
- List<Student> students = new ArrayList<>();
- Connection con = dbConnect();
- PreparedStatement ps = null;
- ResultSet rs = null;
- try {
- ps = con.prepareCall("getStudentHistory");
- rs = ps.executeQuery();
- // Iterate through the data in the result set and load the List
- // while (rs.next()) {
- // students.add(new Student(rs.getInt("StudentId")
- // , rs.getString("LastName")
- // , rs.getString("FirstName")
- // , rs.getInt("Year")
- // , rs.getString("Course Number")
- // , rs.getInt("Units")
- // , rs.getString("Grade")
- // )
- // );
- // }
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- if (rs != null) try { rs.close(); } catch(Exception e) {}
- if (ps != null) try { ps.close(); } catch(Exception e) {}
- if (con != null) try { con.close(); } catch(Exception e) {}
- }
- return students;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement