0

executeUpdate query is not working

int i=ps.executeUpdate(); this line is not working using mvc in jsp String n=request.getParameter("name"); String f=request.getParameter("father"); String m=request.getParameter("mother"); String e=request.getParameter("email"); String c=request.getParameter("contact"); loginbean l=new loginbean(); l.setName(n); l.setFathername(f); l.setMothername(m); l.setEmail(e); l.setContact(c); Class.forName("com.mysql.jdbc.Driver"); out.print("1"); Connection con=DriverManager.getConnection("jdbc:mysql:///mvc","root",""); out.print("2"); PreparedStatement ps=con.prepareStatement("insert into reg (name,father,mother,email,contact) values(?,?,?,?,?);"); out.print("3"); ps.setString(1,l.getName()); ps.setString(2,l.getFathername()); ps.setString(3,l.getMothername()); ps.setString(4,l.getEmail()); ps.setString(5,l.getContact()); out.print("4"); int i=ps.executeUpdate(); out.print("5"); if(i>0) out.print("You are successfully registered..."); } catch ( Exception e) { System.out.println(e); } }

30th Mar 2017, 7:22 AM
CheeKu
CheeKu - avatar
1 Resposta
0
Are you sure the connection is successfully established? Test it with "out.println(con.isConnected());" after creating the connection. If not, check for any errors, e.g. wrong credentials, wrong connection string, driver isn't loaded correct... Does the root account hasn't got any password?
16th Apr 2017, 9:58 PM
ncrypted