@Override public OrderProductDTO selectOrderProduct(int need_orderproductNO) 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, need_orderproductNO); rs = pstmt.executeQuery(); while (rs.next()) { dto = new OrderProductDTO(); dto.setOP_no(rs.getInt(1)); dto.setOP_no(rs.getInt(2)); dto.setOP_pno(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; }
@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) { } } }
@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) { } } }
@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) { } } }
@Override public List<OrderProductDTO> selectsOrderProduct() throws Exception { Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; List<OrderProductDTO> dtolist = null; try { conn = getConnection(); pstmt = conn.prepareStatement( "SELECT " + "OP_NO, OP_ONO, OP_PNO, OP_COUNT, OP_PRICE " + "FROM ORDER_PRICE "); rs = pstmt.executeQuery(); dtolist = new ArrayList<OrderProductDTO>(); while (rs.next()) { OrderProductDTO dto = new OrderProductDTO(); dto.setOP_no(rs.getInt(1)); dto.setOP_ono(rs.getInt(2)); dto.setOP_pno(rs.getInt(3)); dto.setOP_count(rs.getInt(4)); dto.setOP_price(rs.getInt(5)); dtolist.add(dto); } } 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 dtolist; }