executeUpdate() is not working........ Need Solution.....please help,.... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

executeUpdate() is not working........ Need Solution.....please help,....

protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ String a=request.getParameter("Name"); String b=request.getParameter("DOB"); String c=request.getParameter("Email"); String d=request.getParameter("Contact"); String e=request.getParameter("Address"); registrationbean r=new registrationbean(); r.setName(a); r.setDOB(b); r.setEmail(c); r.setContact(d); r.setAddress(e); out.print("1"); Class.forName("com.mysql.jdbc.Driver"); out.print("2"); Connection con= DriverManager.getConnection("jdbc:mysql:///mvc","root",""); out.print("3"); String q="insert into login (Name,DOB,Email,Contact,Password) values ('"+a+"','"+b+"','"+c+"','"+d+"','"+e+"');"; out.print("4"); Statement rs=con.prepareStatement(q); /* rs.setString(1,r.getName()); rs.setString(2,r.getDOB()); rs.setString(3,r.getEmail()); rs.setInt(4,r.getContact()); rs.setString(5,r.getAddress()); */ out.print("5"); rs.executeUpdate(q); out.print("6"); } catch(Exception e) { } } }

20th Feb 2017, 10:31 AM
Aman Sharma
Aman Sharma - avatar
2 Answers
+ 1
the answer you gave is working properly .....a lot of thanks to you ....sirrrrrrrr
21st Feb 2017, 9:17 AM
Aman Sharma
Aman Sharma - avatar
0
assuming you created your table in the order of name dob email contact password then I would not write that inside of the insert statement. just make it print insert into tableName values(1,2,3,4,5); ...according to this^^ their address is their password?? check into that. make sure that the data types in your table are all varchars as you have all strings here. test to make sure all your values are not null, if one of them is I woukd dispatch back to the index url with an error message. .....hope this helps :/
20th Feb 2017, 2:34 PM
Michael Szczepanski
Michael Szczepanski - avatar