Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean DecrementListingQuantity(Listing listing) {
- if (!dbConnStatus) {
- this.PrintDebugMessage("DecrementListingQuantity", "No connection with database");
- return false;
- }
- try {
- Statement stmt;
- dbConn.setAutoCommit(false);
- stmt = dbConn.createStatement();
- stmt.executeUpdate("UPDATE listings SET quantity = quantity - 1 WHERE id = " + listing.getId() + ";" );
- dbConn.commit();
- listing.setNumviews(listing.getQuantity() - 1); //update local object
- return true;
- } catch (SQLException e) {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement