Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Executed successfully in 0.079 s.
- Line 1, column 1
- try{
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/multiple-choicequestionbank?zeroDateTimeBehavior=convertToNull&useSSL=false" , "root", "quangnhat234");
- Statement stmt = (Statement) con.createStatement();
- String questionid = questionidtxt.getText();
- Object questiontype = questiontypecombo.getSelectedItem();
- String questioncontent = qcontenttxt.getText();
- String qanswer1 = qanswer1txt.getText();
- String qanswer2 = qanswer1txt.getText();
- String qanswer3 = qanswer1txt.getText();
- String qanswer4 = qanswer1txt.getText();
- String qcorrect1 = qcorrect1txt.getText();
- String qcorrect2 = qcorrect1txt.getText();
- String qcorrect3 = qcorrect1txt.getText();
- Object difficulty = difficultycombo.getSelectedItem();
- String relevantlesson = relevantlessontxt.getText();
- String QuestionAdd = "INSERT INTO question (QuestionID , Type , Content , QDifficulty, RelevantLesson) VALUES('"+questionid+"' , '"+questiontype+"' , '"+questioncontent+"' , '"+difficulty+"' , '"+relevantlesson+"');";
- stmt.executeUpdate(QuestionAdd);
- String AnswerAdd1 = "INSERT INTO answer (QuestionID , Answer) VALUES( '"+questionid+"' , '"+qanswer1+"' );";
- stmt.executeUpdate(AnswerAdd1);
- String AnswerAdd2 = "INSERT INTO answer (QuestionID , Answer) VALUES( '"+questionid+"' , '"+qanswer2+"' );";
- stmt.executeUpdate(AnswerAdd2);
- String AnswerAdd3 = "INSERT INTO answer (QuestionID , Answer) VALUES( '"+questionid+"' , '"+qanswer3+"' );";
- stmt.executeUpdate(AnswerAdd3);
- String AnswerAdd4 = "INSERT INTO answer (QuestionID , Answer) VALUES( '"+questionid+"' , '"+qanswer4+"' );";
- stmt.executeUpdate(AnswerAdd4);
- String CorrectAdd1 = "INSERT INTO correctanswer (QuestionID , CorrectAnswer) VALUES( '"+questionid+"' , '"+qcorrect1+"' );";
- stmt.executeUpdate(CorrectAdd1);
- String CorrectAdd2 = "INSERT INTO correctanswer (QuestionID , CorrectAnswer) VALUES( '"+questionid+"' , '"+qcorrect2+"' );";
- stmt.executeUpdate(CorrectAdd2);
- String CorrectAdd3 = "INSERT INTO correctanswer (QuestionID , CorrectAnswer) VALUES( '"+questionid+"' , '"+qcorrect3+"' );";
- stmt.executeUpdate(CorrectAdd3);
- commentlbl.setText("Question and Answers are added to the database");
- }
- catch (Exception e) {
- commentlbl.setText("Error while executing request");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement