Guest User

Untitled

a guest
Jan 24th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
  2. // TODO add your handling code here:
  3. String b6_1_1 = jTextField18.getText();
  4. String b6_2_1 = jTextField19.getText();
  5. String b6_3_1 = jTextField20.getText();
  6. boolean b6_check = true;
  7. int b6_1_2 = 0;
  8. int b6_2_2 = 0;
  9. int b6_3_2 = 0;
  10. if (isNumeric(b6_1_1)) {
  11. b6_1_2 = Integer.parseInt(b6_1_1);
  12. }
  13. else {
  14. b6_check = false;
  15. JOptionPane.showMessageDialog(this, "'Admission no.' must be integral");
  16. }
  17. if (isNumeric(b6_2_1)) {
  18. b6_2_2 = Integer.parseInt(b6_2_1);
  19. }
  20. else {
  21. b6_check = false;
  22. JOptionPane.showMessageDialog(this, "'Year' must be integral");
  23. }
  24. if (isNumeric(b6_3_1)) {
  25. b6_3_2 = Integer.parseInt(b6_3_1);
  26. }
  27. else {
  28. b6_check = false;
  29. JOptionPane.showMessageDialog(this, "'Term' must be integral");
  30. }
  31. if (b6_check)
  32. {
  33. try {
  34. Class.forName("java.sql.DriverManager");
  35. Connection c6 = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project", "informatics", "IPProject");
  36. Statement s6 = (Statement) c6.createStatement();
  37. String q6_s = "SELECT subject, score, maximum_marks ";
  38. String q6_f = "FROM marks, examinations ";
  39. String q6_w1 = "WHERE (admission_number = " + b6_1_2 + " AND marks.examination_id = examinations.examination_id ";
  40. String q6_w2 = "AND year = " + b6_2_2 + " AND term = " + b6_3_2 + " );";
  41. ResultSet r6_1 = s6.executeQuery(q6_s + q6_f + q6_w1 + q6_w2);
  42. String output = "";
  43. ResultSet r6_2 = s6.executeQuery("SELECT * FROM students WHERE admission_number = " + b6_1_2);
  44. //Adding Name
  45. output = output + "Name : " + r6_2.getString("name") + "\n";
  46. //Adding Roll number
  47. output = output + "Roll no. : " + r6_2.getString("roll_number") + "\n";
  48. //Adding Class and Section
  49. output = output + "Class :" + r6_2.getString("class") + " Section :" + r6_2.getString("section") + "\n";
  50. while (r6_1.next()) {
  51. String r6_s = r6_1.getString("subject");
  52. String r6_m = r6_1.getString("score");
  53. String r6_mm = r6_1.getString("maximum_marks");
  54. output = output + r6_s + " : " + r6_m + "/" + r6_mm + "\n";
  55. }
  56. JOptionPane.showMessageDialog (this, output);
  57. clear6();
  58. }
  59. catch (Exception e6) {
  60. JOptionPane.showMessageDialog(this, e6.getMessage());
  61. }
  62. }
  63. }
Add Comment
Please, Sign In to add comment