Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. Executed successfully in 0.079 s.
  2. Line 1, column 1
  3.  
  4. try{
  5. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/multiple-choicequestionbank?zeroDateTimeBehavior=convertToNull&useSSL=false" , "root", "quangnhat234");
  6. Statement stmt = (Statement) con.createStatement();
  7.  
  8. String questionid = questionidtxt.getText();
  9. Object questiontype = questiontypecombo.getSelectedItem();
  10. String questioncontent = qcontenttxt.getText();
  11. String qanswer1 = qanswer1txt.getText();
  12. String qanswer2 = qanswer1txt.getText();
  13. String qanswer3 = qanswer1txt.getText();
  14. String qanswer4 = qanswer1txt.getText();
  15. String qcorrect1 = qcorrect1txt.getText();
  16. String qcorrect2 = qcorrect1txt.getText();
  17. String qcorrect3 = qcorrect1txt.getText();
  18. Object difficulty = difficultycombo.getSelectedItem();
  19. String relevantlesson = relevantlessontxt.getText();
  20.  
  21. String QuestionAdd = "INSERT INTO question (QuestionID , Type , Content , QDifficulty, RelevantLesson) VALUES('"+questionid+"' , '"+questiontype+"' , '"+questioncontent+"' , '"+difficulty+"' , '"+relevantlesson+"');";
  22. stmt.executeUpdate(QuestionAdd);
  23.  
  24. String AnswerAdd1 = "INSERT INTO answer (QuestionID , Answer) VALUES( '"+questionid+"' , '"+qanswer1+"' );";
  25. stmt.executeUpdate(AnswerAdd1);
  26.  
  27. String AnswerAdd2 = "INSERT INTO answer (QuestionID , Answer) VALUES( '"+questionid+"' , '"+qanswer2+"' );";
  28. stmt.executeUpdate(AnswerAdd2);
  29.  
  30. String AnswerAdd3 = "INSERT INTO answer (QuestionID , Answer) VALUES( '"+questionid+"' , '"+qanswer3+"' );";
  31. stmt.executeUpdate(AnswerAdd3);
  32.  
  33. String AnswerAdd4 = "INSERT INTO answer (QuestionID , Answer) VALUES( '"+questionid+"' , '"+qanswer4+"' );";
  34. stmt.executeUpdate(AnswerAdd4);
  35.  
  36. String CorrectAdd1 = "INSERT INTO correctanswer (QuestionID , CorrectAnswer) VALUES( '"+questionid+"' , '"+qcorrect1+"' );";
  37. stmt.executeUpdate(CorrectAdd1);
  38.  
  39. String CorrectAdd2 = "INSERT INTO correctanswer (QuestionID , CorrectAnswer) VALUES( '"+questionid+"' , '"+qcorrect2+"' );";
  40. stmt.executeUpdate(CorrectAdd2);
  41.  
  42. String CorrectAdd3 = "INSERT INTO correctanswer (QuestionID , CorrectAnswer) VALUES( '"+questionid+"' , '"+qcorrect3+"' );";
  43. stmt.executeUpdate(CorrectAdd3);
  44.  
  45. commentlbl.setText("Question and Answers are added to the database");
  46. }
  47.  
  48. catch (Exception e) {
  49. commentlbl.setText("Error while executing request");
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement