By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,651 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,651 IT Pros & Developers. It's quick & easy.

fetch data from database(mysql)

P: 1
Expand|Select|Wrap|Line Numbers
  1. public static CustomizedBean generatePaper(CustomizedBean paperAttribute,String []chapters)
  2.     {
  3.         Statement stmt = null;
  4.         String mcq = paperAttribute.getMcq(); //no of question specified by user
  5.         String fill = paperAttribute.getFill();//no of question specified by user
  6.         String trueFalse=paperAttribute.getTrueFalse();//no of question specified by user
  7.         String shortType = paperAttribute.getShort();//no of question specified by user
  8.         String mediumType = paperAttribute.getMedium();//no of question specified by user
  9.         String longType=paperAttribute.getLong();//no of question specified by user
  10. /****************************************************************************************************/
  11.         String examName=paperAttribute.getExamName();
  12.         String DiffLevel=paperAttribute.getLevel(); //easy,moderate and hard
  13.         String FullMarks=paperAttribute.getFulllMarks();
  14.         try
  15.         {
  16.             currentCon = ConnectionManager.getConnection();
  17.             stmt=currentCon.createStatement();    
  18.  
  19.             for(String chapterId: chapters){
  20.                 String CollectQuestionsQuery = "select questionId,chapterId from questionbank where chapterId='"+chapterId+"'";
  21.                 rs=stmt.executeQuery(CollectQuestionsQuery);
  22.                 rs.next();
  23.                 int answerType=rs.getInt(1);
  24.                 switch(answerType){
  25.                     case 1:{//collect MCQ questions
  26.                         String mcqQuestionQuery= "select * from questionbank where chapterId='"+chapterId+"'";
  27.                         rsMcq=stmt.executeQuery(mcqQuestionQuery);
  28.  
  29.                     }
  30.                 }
  31.             }
  32.             paperAttribute.valid=true;
  33.             stmt.close();
  34.             currentCon.close();
  35.         }
  36.         catch (Exception ex)
  37.         {
  38.             paperAttribute.valid=false;
  39.             System.out.println("An Exception has occurred: " + ex);
  40.         }
  41.         return paperAttribute;
  42.     }
  43. }
__________________________________________________ ______

i am lost here. I am trying to generate question paper. From jsp if user has 3 option to to choose difficulty level (easy,moderate and hard). Then based upon the difficult level it then goes for selecting question(based upon topic Id,msq,long,short answer type supplied by the user). Then based upon that i want to selects all the question at once and send it to jsp via servlet.here i ll also have to take full marks in to account.
how can i keep all the questions and make it available for further processing
Apr 26 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.