Пример #1
0
  @Override
  public void deleteOrderProduct(OrderProductDTO orderproduct) throws Exception {

    Connection conn = null;
    PreparedStatement pstmt = null;

    try {
      conn = getConnection();
      pstmt = conn.prepareStatement("DELETE FROM ORDER_PRODUCT WHERE OP_NO=?");
      pstmt.setInt(1, orderproduct.getOP_no());

      pstmt.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (pstmt != null)
        try {
          pstmt.close();
        } catch (SQLException se) {
        }
      if (conn != null)
        try {
          conn.close();
        } catch (SQLException se) {
        }
    }
  }
Пример #2
0
  @Override
  public OrderProductDTO selectOrderProduct(OrderProductDTO orderproduct) throws Exception {

    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    OrderProductDTO dto = null;

    try {
      conn = getConnection();
      pstmt =
          conn.prepareStatement(
              "SELECT "
                  + "OP_NO, OP_ONO, OP_PNO, OP_COUNT, OP_PRICE "
                  + "FROM ORDER_PRODUCT "
                  + "WHERE OP_NO=?");
      pstmt.setInt(1, orderproduct.getOP_no());

      rs = pstmt.executeQuery();

      while (rs.next()) {
        dto = new OrderProductDTO();
        dto.setOP_no(rs.getInt(1));
        dto.setOP_ono(rs.getInt(2));
        dto.setOP_no(rs.getInt(3));
        dto.setOP_count(rs.getInt(4));
        dto.setOP_price(rs.getInt(5));
      }

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (rs != null)
        try {
          rs.close();
        } catch (SQLException se) {
        }
      if (pstmt != null)
        try {
          pstmt.close();
        } catch (SQLException se) {
        }
      if (conn != null)
        try {
          conn.close();
        } catch (SQLException se) {
        }
    }
    return dto;
  }
Пример #3
0
  @Override
  public void updateOrderProduct(OrderProductDTO orderproduct) throws Exception {

    Connection conn = null;
    PreparedStatement pstmt = null;

    try {
      conn = getConnection();
      pstmt =
          conn.prepareStatement(
              "UPDATE "
                  + "ORDER_PRODUCT "
                  + "SET OP_ONO=?, OP_PNO=?, OP_COUNT, OP_PRICT "
                  + "WHERE OP_NO=?");
      pstmt.setInt(1, orderproduct.getOP_ono());
      pstmt.setInt(2, orderproduct.getOP_pno());
      pstmt.setInt(3, orderproduct.getOP_count());
      pstmt.setInt(4, orderproduct.getOP_price());
      pstmt.setInt(5, orderproduct.getOP_no());

      pstmt.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (pstmt != null)
        try {
          pstmt.close();
        } catch (SQLException se) {
        }
      if (conn != null)
        try {
          conn.close();
        } catch (SQLException se) {
        }
    }
  }
Пример #4
0
  @Override
  public void insertOrderProduct(OrderProductDTO orderproduct) throws Exception {

    Connection conn = null;
    PreparedStatement pstmt = null;

    try {
      conn = getConnection();
      pstmt =
          conn.prepareStatement(
              "INSERTO INTO ORDER_PRODUCT "
                  + "(OP_NO, OP_ONO, OP_PNO, OP_COUNT, OP_PRICE) "
                  + "VALUES "
                  + "(ORDER_PRODUCT_SEQ.NEXTVAL,?,?,?,?)");
      pstmt.setInt(1, orderproduct.getOP_no());
      pstmt.setInt(2, orderproduct.getOP_ono());
      pstmt.setInt(3, orderproduct.getOP_pno());
      pstmt.setInt(4, orderproduct.getOP_count());
      pstmt.setInt(5, orderproduct.getOP_price());

      pstmt.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (pstmt != null)
        try {
          pstmt.close();
        } catch (SQLException se) {
        }
      if (conn != null)
        try {
          conn.close();
        } catch (SQLException se) {
        }
    }
  }