Class AnswerDAO


  • public class AnswerDAO
    extends Object
    This class is made to access database only (table SB_Question_Answer)
    Author:
    neysseri
    • Method Detail

      • recordThisAnswerAsVote

        public static void recordThisAnswerAsVote​(Connection con,
                                                  ResourceReference questionPK,
                                                  AnswerPK answerPK)
                                           throws SQLException
        Record that the answer (answerPK) has been chosen to the question (questionPK)
        Parameters:
        con - the Connection
        questionPK - the QuestionPK (question id)
        answerPK - the AnswerPK (answer id)
        Throws:
        SQLException
      • addAnswerToAQuestion

        public static void addAnswerToAQuestion​(Connection con,
                                                Answer answer,
                                                ResourceReference questionPK)
                                         throws SQLException
        Add an answer to a question
        Parameters:
        con - the Connection
        answer - the Answer
        questionPK - the QuestionPK (question id)
        Throws:
        SQLException
      • deleteAnswersToAQuestion

        public static void deleteAnswersToAQuestion​(Connection con,
                                                    ResourceReference questionPK)
                                             throws SQLException
        Delete all answers to a given question
        Parameters:
        con - the Connection
        questionPK - the QuestionPK (question id)
        Throws:
        SQLException
      • deleteAnswerToAQuestion

        public static void deleteAnswerToAQuestion​(Connection con,
                                                   ResourceReference questionPK,
                                                   String answerId)
                                            throws SQLException
        Delete an answer to a question
        Parameters:
        con - the Connection
        questionPK - the QuestionPK (question id)
        answerId - the answer id
        Throws:
        SQLException
      • deleteAnswersToAllQuestions

        public static void deleteAnswersToAllQuestions​(Connection con,
                                                       String instanceId)
                                                throws SQLException
        Deletes all the answers of all the questions relative to the specified component instance.
        Parameters:
        con - the connection to the database.
        instanceId - the unique identifier of the component instance.
        Throws:
        SQLException - if an error occurs while deleting the answers.
      • updateAnswerToAQuestion

        public static void updateAnswerToAQuestion​(Connection con,
                                                   ResourceReference questionPK,
                                                   Answer answer)
                                            throws SQLException
        Update an answer to a question
        Parameters:
        con - the Connection
        questionPK - the QuestionPK (question id)
        answer - the Answer
        Throws:
        SQLException