Beispiel #1
0
  public void inserirItem(Item item) {
    String sql =
        "insert into item"
            + "(name, price, description, urlImage, id_restaurant, id_type)"
            + "values (?, ?, ?, ?, ?, ?)";
    try {
      PreparedStatement stmt = connection.prepareStatement(sql);

      stmt.setString(1, item.getName());
      stmt.setDouble(2, item.getPrice());
      stmt.setString(3, item.getDescription());
      stmt.setString(4, item.getUrlImage());
      stmt.setInt(5, item.getIdRestaurante());
      stmt.setInt(6, item.getIdType());

      stmt.execute();
      stmt.close();
    } catch (SQLException e) {
      throw new RuntimeException(e);
    }
  }