public void addProductToDatabase(Product p) throws SQLException { int number = p.getNumber(); String name = p.getName(); BigDecimal price = p.getUnitPrice(); int quantity = p.getQuantity(); String category = p.getCategory(); String car = p.getCar(); String image = p.getImage(); Statement stmt = con.createStatement(); String sql = "INSERT INTO APP.PRODUCTS " + "VALUES (" + number + ",'" + name + "'," + quantity + ",'" + category + "','" + image + "','" + car + "'," + price + ")"; stmt.executeUpdate(sql); }
public void removeProductFromDatabase(Product p) throws SQLException { int number = p.getNumber(); String name = p.getName(); BigDecimal price = p.getUnitPrice(); int quantity = p.getQuantity(); String category = p.getCategory(); String car = p.getCar(); String image = p.getImage(); Statement stmt = con.createStatement(); String sql = "DELETE FROM App.Products WHERE number=" + number; stmt.executeUpdate(sql); }