0

I have a table: "server" like below:

id    status
------------
123   0
234   0
156   0
------------

I have written an update query to update the status like:

String qry = "update server set status=? where server_id in (123)";
PreparedStatement pst = conn.prepareStatement(query);
pst.setInt(1,10);
result = pst.executeUpdate();

Printing the result value here.

But in db for that particular "id" status is updated, but it returned "result" value as 0 instead of 1.

Mirza Sisic
  • 2,401
  • 4
  • 24
  • 38
  • Are you getting any error messages? – bradimus Aug 30 '16 at 13:33
  • try "update server set status=? where id=123" – Abdelhak Aug 30 '16 at 13:39
  • re-read your query again, according to *server* table you provided your query should throw an exception, which you are probably ignoring with a do nothing catch statement such as `catch(Excection e){}`, never do that. –  Sep 15 '17 at 19:50
  • This question was caused by a problem that **can no longer be reproduced** or a **simple typographical error**. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting. –  Sep 15 '17 at 19:51
  • [What does your step debugger tell you?](http://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) –  Sep 15 '17 at 19:51
  • @JarrodRobertson How can this update possibly (a) update the database and (b) return zero if an exception was thrown? You aren't making any sense. I suggest you lay off. – user207421 Sep 15 '17 at 23:22

0 Answers0