Esempio n. 1
0
  @Override
  public Order getOrdersByName(String orderNameToCheck) {
    Order requestedOrder = null;
    try {

      cs = bd.getConn().prepareCall("{call getOrder(?)}");
      cs.setString(1, orderNameToCheck);
      ResultSet rs = cs.executeQuery();

      while (rs.next()) {

        requestedOrder.setIdOrder(rs.getInt("id_order"));
        requestedOrder.setDate(rs.getDate("date"));
        requestedOrder.setSubtotal(rs.getDouble("subtotal"));
        requestedOrder.setTotal(rs.getDouble("total"));
      }
    } catch (Exception e) {
      System.out.println(e);
    }
    return requestedOrder;
  }
Esempio n. 2
0
  @Override
  public ArrayList<Order> getAll() {
    ArrayList<Order> orderList = new ArrayList<>();

    try {

      cs = bd.getConn().prepareCall("{call getAllOrders()}");
      ResultSet rs = cs.executeQuery();

      while (rs.next()) {
        Order orderToBeAdded = null;
        orderToBeAdded.setIdOrder(rs.getInt("id_order"));
        orderToBeAdded.setDate(rs.getDate("date"));
        orderToBeAdded.setSubtotal(rs.getDouble("subtotal"));
        orderToBeAdded.setTotal(rs.getDouble("Total"));

        orderList.add(orderToBeAdded);
      }
    } catch (Exception e) {

    }
    return orderList;
  }