How To Correct This Error?
I am developing android App and I am using RestFul Webservices.I have used multiPartEntity to send data from client side to server.I don't have any error in client side.but I have
Solution 1:
It is a sql syntax error try to print the values of hotelParams.getBodyParts().get(0)
and hotelParams.getBodyParts().get(1)
1.Try to Check whether you are getting strings or not.
2.Try to check whitespaces in between sql query
3.Try to edit ur code by putting something like this
@POST@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public void postHotel(@FormDataParam("user_name") String userName
@FormDataParam("password") String password)
throws SQLException, FileNotFoundException, IOException {
stmt.executeUpdate("insert into hotel(user_name,password)values('"
+userName
+ "','"
+password
+ "');
Solution 2:
Why do you are using multipart for this purpose? Please use only two args, user and password. I recommend to you start with this easy solution:
@Path("/user/{username}/{password}")
public void postHotel(@PathParam("username") String username, @PathParam("password") String password) {
stmt.executeUpdate("insert into hotel(username,password)values('"
+hotelParams.getBodyParts().get(0)
+ "','"
+ hotelParams.getBodyParts().get(1)
+ "');
Solution 3:
@POST@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public void postHotel(MultiPart hotelParams)
throws SQLException, FileNotFoundException, IOException {
stmt.executeUpdate("insert into hotel(user_name,password)values('"
+hotelParams.getBodyParts().get(0)
+ "','"
+ hotelParams.getBodyParts().get(1)
+ "'");
Post a Comment for "How To Correct This Error?"