public static int generateResult(Bean beanobj) throws NullPointerException, SQLException {

		int total=0;
		try {

			con = DBConnection.getConnection();
			//String query1 = "select question.answer,testresult.capturedanswer from question,testresult,test where test.testid='"+beanobj.getTestid()+"'and test.questionid=question.questionid and testresult.questionid=question.questionid and testresult.studentid='"+beanobj.getStudentid()+"'";
			String query1="select question.answer,testresult.capturedanswer from question,testresult where testresult.testid='"+beanobj.getTestid()+"' and testresult.studentid='"+beanobj.getStudentid()+"' and testresult.questionid=question.questionid";
			String query2 = "insert into result1(testid,studentid,score,schoolid,average) values(?,?,?,?,?)";

			st = con.createStatement();
			rs=st.executeQuery(query1);

			/*if(rs.next()){
				i=1;
			}*/
			while(rs.next()){
				i=1;
				System.out.println(rs.getString(1));
				System.out.println(rs.getString(2));
				if(rs.getString(1).equalsIgnoreCase(rs.getString(2)))
				{
					System.out.println("answer is correct give 1 mark");
					total++;

				}
				else
				{
					System.out.println("answer is not correct give 0 mark");
					//total=total+0;
				}

			}
			System.out.println(total);

			pt = con.prepareStatement(query2);
			int avg1=(total*100);
			int avg=avg1/10;
			System.out.println(avg);

			pt.setString(1, beanobj.getTestid());
			pt.setString(2, beanobj.getStudentid());
			pt.setInt(3,total);
			pt.setString(4,beanobj.getSchoolid());
			pt.setFloat(5,avg);

			pt.executeUpdate();
			con.commit();


		} catch (Exception e) {
			i=10;
			return i;

		} finally {
			con.close();



		}


		return total;	

	}