+ 3

Hello every one, i have an issue in the returned value of exectuteUpdate in java, first "UserName" is a primary key in sql tabl

String Query = "insert into user values ( '"+ UserName +"', '"+PassWord +"', '"+ mobile +"' ) ;" ; statm = Cnx.GetConnexion().createStatement(); ArrayList<Integer> list = new ArrayList<>(); int row = statm.executeUpdate(Query); if( row > 0 ) // insertion with succes { pw.println("inserted with succes ! row =" +row); //response.sendRedirect("index.html"); } else

7th May 2017, 11:05 PM
HaMza BouRouissa
HaMza BouRouissa - avatar
2 odpowiedzi
+ 2
What happens if you put single quotes around your strings in the query? Something like: "insert into table values('" + name + "') ;" Note the single and double quotes on either side of the name variable
10th May 2017, 5:17 AM
botheredbybees
botheredbybees - avatar
+ 1
that's what i done, but the problem isn't here.
15th May 2017, 11:15 PM
HaMza BouRouissa
HaMza BouRouissa - avatar