Guest User

Untitled

a guest
Apr 2nd, 2018
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. PrintWriter out = response.getWriter();
  2. String answr="";
  3. String ques = request.getParameter("ques");
  4. String lang = request.getParameter("lang");
  5. String opt1=request.getParameter("opt1");
  6. String opt2=request.getParameter("opt2");
  7. String opt3=request.getParameter("opt3");
  8. String opt4=request.getParameter("opt4");
  9. String ans[]=request.getParameterValues("opt");
  10. int i;
  11. for(i=0;i<ans.length;i++)
  12. {
  13. answr=ans[i];
  14. }
  15. try{
  16. Class.forName("oracle.jdbc.driver.OracleDriver");
  17. Connection con=DriverManager.getConnection(
  18. "jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
  19.  
  20. PreparedStatement ps=con.prepareStatement("insert into addques values(add_ques.NEXTVAL,?,?,?,?,?,?,?)");
  21. ps.setString(2,ques);
  22. ps.setString(3,opt1);
  23. ps.setString(4,opt2);
  24. ps.setString(5,opt3);
  25. ps.setString(6,opt4);
  26. ps.setString(7,answr);
  27. ps.setString(8,lang );
  28. int j=ps.executeUpdate();
  29. if(j>0)
  30. {
  31. out.println("<script language='javascript'>alert('Account successfully created! Login to continue!'); window.location.href=welcome.jsp'</script>");
  32. }
  33. }
  34. catch (Exception e2) {System.out.println(e2);
  35. }
  36.  
  37. out.close();
Add Comment
Please, Sign In to add comment