Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. CREATE PROC [dbo].[getStudentHistory]
  2.  
  3. @studentId INT
  4. AS
  5.  
  6. SELECT LastName, FirstName, Year, Term, C.Prefix + ' ' + CAST(C.Num AS CHAR(3)) + ' - ' + SEC.Letter AS [Course Number],
  7. Units, isNull(G.Letter, ' ') AS Grade
  8. FROM Student S
  9.  
  10. INNER JOIN StudentInSection SIS
  11. ON S.StudentId = SIS.StudentId
  12. INNER JOIN Section SEC
  13. ON SEC.SectionId = SIS.SectionId
  14. INNER JOIN Course C
  15. ON C.CourseId = SEC.CourseId
  16. LEFT OUTER JOIN Grade G
  17. ON G.GradeId = SIS.GradeId
  18. INNER JOIN Semester SEM
  19. ON SEM.SemesterId = SEC.SemesterId
  20.  
  21. WHERE S.StudentId = @studentId
  22. Order BY Units DESC
  23.  
  24. @SuppressWarnings("resource")
  25. public static void showStudentHistory()
  26. {
  27.  
  28. System.out.print("n Please enter the Id of a current student you wanna see grades for");
  29. System.out.print("n==>");
  30.  
  31. Scanner insertstudentID = new Scanner(System.in);
  32. int passedStudentID = insertstudentID.nextInt() ;
  33.  
  34. Student student = new Student(passedStudentID, null, null);
  35. List<Student> students = student.getStudentHistory(passedStudentID);
  36. String tabs = "tt";
  37. System.out.println("LastName"+ tabs + "FirstName"+ tabs + "Year"+ tabs + "Term"+ tabs + "Course Number"+ tabs + "Units"+ tabs + "Grade");
  38. System.out.println("---------"+ tabs + "---------"+ tabs + "--------"+ tabs + "-----------");
  39.  
  40.  
  41. // Student tempStu = students.get(passedStudentID);
  42. // System.out.println(tempStu.getmStudentId() + "ttt" +
  43. // padRight(tempStu.getmFirstName(), 15) + "tt" +
  44. // padRight(tempStu.getmLastName(), 15) + "tt" +
  45. // tempStu.getmNum());
  46.  
  47. Scanner kb = new Scanner(System.in);
  48. System.out.print("nHit Enter to continue...");
  49. String discard = kb.nextLine();
  50.  
  51. public List<Student> getStudentHistory(int StudentID) {
  52.  
  53. List<Student> students = new ArrayList<>();
  54. Connection con = dbConnect();
  55. PreparedStatement ps = null;
  56. ResultSet rs = null;
  57. try {
  58. ps = con.prepareCall("getStudentHistory");
  59. rs = ps.executeQuery();
  60. // Iterate through the data in the result set and load the List
  61. // while (rs.next()) {
  62. // students.add(new Student(rs.getInt("StudentId")
  63. // , rs.getString("LastName")
  64. // , rs.getString("FirstName")
  65. // , rs.getInt("Year")
  66. // , rs.getString("Course Number")
  67. // , rs.getInt("Units")
  68. // , rs.getString("Grade")
  69. // )
  70. // );
  71. // }
  72. } catch (SQLException e) {
  73. e.printStackTrace();
  74. } finally {
  75. if (rs != null) try { rs.close(); } catch(Exception e) {}
  76. if (ps != null) try { ps.close(); } catch(Exception e) {}
  77. if (con != null) try { con.close(); } catch(Exception e) {}
  78. }
  79. return students;
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement