Advertisement
Guest User

Untitled

a guest
Jul 8th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. String result = "";
  2. String userid = request.getParameter("userid");
  3. String pswd = request.getParameter("pswd");
  4. String name = request.getParameter("name");
  5.  
  6. request.setCharacterEncoding("UTF-8");
  7. String bloodgroup = request.getParameter("bloodgroup");
  8. String mob = request.getParameter("mob");
  9. String city = request.getParameter("city");
  10. String Availability = request.getParameter("Availability");
  11. try {
  12. Class.forName("com.mysql.jdbc.Driver");
  13. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/blood", "root", "root");
  14.  
  15. String s = "insert into registration values(?,?,?,?,?,?,?)";
  16. PreparedStatement ps = con.prepareStatement(s);
  17.  
  18. ps.setString(1, name);
  19. ps.setBytes(2, bloodgroup.getBytes("UTF-8"));
  20. ps.setString(3, mob);
  21. ps.setString(4, city);
  22.  
  23. ps.setString(5, userid);
  24. ps.setString(6, pswd);
  25. ps.setString(7, Availability);
  26. int x = ps.executeUpdate();
  27. if (x > 0) {
  28. result = "Data Saved";
  29. }
  30. } catch (Exception e) {
  31. result = e.toString();
  32. }
  33. PrintWriter pw = response.getWriter();
  34. pw.write(result);
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement