Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public boolean DecrementListingQuantity(Listing listing) {
  2. if (!dbConnStatus) {
  3. this.PrintDebugMessage("DecrementListingQuantity", "No connection with database");
  4. return false;
  5. }
  6.  
  7. try {
  8. Statement stmt;
  9. dbConn.setAutoCommit(false);
  10. stmt = dbConn.createStatement();
  11. stmt.executeUpdate("UPDATE listings SET quantity = quantity - 1 WHERE id = " + listing.getId() + ";" );
  12. dbConn.commit();
  13. listing.setNumviews(listing.getQuantity() - 1); //update local object
  14. return true;
  15. } catch (SQLException e) {
  16. return false;
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement