public void insertCardInventory(Card card, Collection collection, int newValue) { PreparedStatement insertInventory; Connection swdb = su.getDbConnection(); try { insertInventory = swdb.prepareStatement( "INSERT INTO Collection (CollectionName, CardID, Inventory) " + "VALUES( ?, ?, ? ) "); insertInventory.setString(1, collection.getCollectionName()); insertInventory.setInt(2, card.getCardId()); insertInventory.setInt(3, newValue); insertInventory.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } su.closeDB(); }
public void updateCardDeckInventory(Card card, Deck deck, int newValue) { PreparedStatement updateInventory; Connection swdb = su.getDbConnection(); try { updateInventory = swdb.prepareStatement( "UPDATE Deck SET Inventory = ? " + " WHERE DeckName = ? AND ID = ? "); updateInventory.setInt(1, newValue); updateInventory.setString(2, deck.getName()); updateInventory.setInt(3, card.getCardId()); updateInventory.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } su.closeDB(); }