Guest User

Untitled

a guest
Apr 21st, 2018
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. String id[]= new String[5];
  2. for(int i=1;i<=5;i++)
  3. {
  4. id[i]=request.getParameter("opt"+i);
  5. System.out.println(id[i]);
  6.  
  7. }
  8.  
  9. try{
  10. Class.forName("oracle.jdbc.driver.OracleDriver");
  11. Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "nivt", "1234");
  12. Statement stmt=connection.createStatement();
  13. ResultSet rs=stmt.executeQuery("Select * from addques");
  14. int count=0;
  15. while(rs.next())
  16. {
  17. String str[]= new String[5];
  18. for(int j=1;j<=5;j++){
  19. str[j]=rs.getString("correctopt");
  20. System.out.println(str[j]);
  21. }
  22.  
  23.  
  24. for(int i=0;i<str.length;i++){
  25. if(id.equals(str)){
  26.  
  27. count++;
  28.  
  29. }
  30. }
  31. }
  32. out.println("Your "+count+" answers are correct");
  33. }
  34. catch(Exception e)
  35. {
  36. System.out.print(e);
  37. }
Add Comment
Please, Sign In to add comment