亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? orderbean.java

?? 本教程介紹j2ee企業開發方面的知識
?? JAVA
字號:
/* * * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. *  * This software is the proprietary information of Sun Microsystems, Inc.   * Use is subject to license terms. *  */import java.sql.*;import javax.sql.*;import java.util.*;import javax.ejb.*;import javax.naming.*;public class OrderBean implements EntityBean {   private String orderId;   private ArrayList lineItems;   private String customerId;   private double totalPrice;   private String status;   private Connection con;   private String dbName = "java:comp/env/jdbc/OrderDB";   private EntityContext context;   public ArrayList getLineItems() {      System.out.println("in getLineItems");      return lineItems;   }   public String getCustomerId() {      return customerId;   }   public double getTotalPrice() {      return totalPrice;   }       public String getStatus() {      return status;   }   public String ejbCreate(String orderId, String customerId,       String status, double totalPrice, ArrayList lineItems)       throws CreateException {          System.out.println("in ejbCreate");       try {          insertOrder(orderId, customerId, status, totalPrice);          for (int i = 0; i < lineItems.size(); i++) {             LineItem item = (LineItem)lineItems.get(i);             insertItem(item);          }       } catch (Exception ex) {           throw new EJBException("ejbCreate: " +               ex.getMessage());       }       this.orderId = orderId;       this.customerId = customerId;       this.status = status;       this.totalPrice = totalPrice;       this.lineItems = lineItems ;       System.out.println("about to leave ejbCreate");       return orderId;   }        public String ejbFindByPrimaryKey(String primaryKey)       throws FinderException {      boolean result;      try {         result = selectByPrimaryKey(primaryKey);       } catch (Exception ex) {           throw new EJBException("ejbFindByPrimaryKey: " +               ex.getMessage());       }      if (result) {         return primaryKey;      }      else {         throw new ObjectNotFoundException            ("Row for id " + primaryKey + " not found.");      }   }   public Collection ejbFindByProductId(String productId)      throws FinderException {      Collection result;      try {         result = selectByProductId(productId);       } catch (Exception ex) {           throw new EJBException("ejbFindByProductId " +               ex.getMessage());       }       return result;   }   public void ejbRemove() {      try {         deleteOrder(orderId);         deleteItems(orderId);       } catch (Exception ex) {           throw new EJBException("ejbRemove: " +               ex.getMessage());       }   }    public void setEntityContext(EntityContext context) {      this.context = context;      try {         makeConnection();      } catch (Exception ex) {          throw new EJBException("Unable to connect to database. " +             ex.getMessage());      }   }   public void unsetEntityContext() {      try {         con.close();      } catch (SQLException ex) {          throw new EJBException("unsetEntityContext: " + ex.getMessage());      }   }   public void ejbActivate() {      orderId = (String)context.getPrimaryKey();   }   public void ejbPassivate() {      orderId = null;   }      public void ejbLoad() {      try {         loadOrder();         loadItems();       } catch (Exception ex) {           throw new EJBException("ejbLoad: " +              ex.getMessage());       }   }   public void ejbStore() {      try {         storeOrder();         for (int i = 0; i < lineItems.size(); i++) {            LineItem item = (LineItem)lineItems.get(i);            storeItem(item);         }       } catch (Exception ex) {           throw new EJBException("ejbLoad: " +              ex.getMessage());       }   }   public void ejbPostCreate(String orderId, String customerId,       String status, double totalPrice, ArrayList lineItems) { }/*********************** Database Routines *************************/   private void makeConnection() throws NamingException, SQLException {      InitialContext ic = new InitialContext();      DataSource ds = (DataSource) ic.lookup(dbName);      con =  ds.getConnection();   }   private void insertOrder (String orderId, String customerId,       String status, double totalPrice) throws SQLException {          String insertStatement =                "insert into orders values ( ? , ? , ? , ? )";          PreparedStatement prepStmt =                 con.prepareStatement(insertStatement);          prepStmt.setString(1, orderId);          prepStmt.setString(2, customerId);          prepStmt.setDouble(3, totalPrice);          prepStmt.setString(4, status);          prepStmt.executeUpdate();          prepStmt.close();   }   private void insertItem(LineItem lineItem)       throws SQLException {          String insertStatement =                "insert into lineitems values ( ? , ? , ? , ? , ? )";          PreparedStatement prepStmt =                 con.prepareStatement(insertStatement);          prepStmt.setInt(1, lineItem.getItemNo());          prepStmt.setString(2, lineItem.getOrderId());          prepStmt.setString(3, lineItem.getProductId());          prepStmt.setDouble(4, lineItem.getUnitPrice());          prepStmt.setInt(5, lineItem.getQuantity());          prepStmt.executeUpdate();          prepStmt.close();   }   private boolean selectByPrimaryKey(String primaryKey)       throws SQLException {      String selectStatement =            "select orderid " +            "from orders where orderid = ? ";      PreparedStatement prepStmt =            con.prepareStatement(selectStatement);      prepStmt.setString(1, primaryKey);      ResultSet rs = prepStmt.executeQuery();      boolean result = rs.next();      prepStmt.close();      return result;   }   private Collection selectByProductId(String productId)       throws SQLException {      String selectStatement =            "select distinct orderid " +            "from lineitems where productid = ? ";      PreparedStatement prepStmt =             con.prepareStatement(selectStatement);      prepStmt.setString(1, productId);      ResultSet rs = prepStmt.executeQuery();      ArrayList a = new ArrayList();      while (rs.next()) {         String id = rs.getString(1);         a.add(id);      }      prepStmt.close();      return a;   }   private void deleteItems(String orderId) throws SQLException {      String deleteStatement =            "delete from lineitems  " +            "where orderid = ?";      PreparedStatement prepStmt =            con.prepareStatement(deleteStatement);      prepStmt.setString(1, orderId);      prepStmt.executeUpdate();      prepStmt.close();   }   private void deleteOrder(String orderId) throws SQLException {      String deleteStatement =            "delete from orders  " +            "where orderid = ?";      PreparedStatement prepStmt =            con.prepareStatement(deleteStatement);      prepStmt.setString(1, orderId);      prepStmt.executeUpdate();      prepStmt.close();   }   private void loadOrder() throws SQLException {      String selectStatement =            "select customerid, totalprice, status " +            "from orders where orderid = ? ";      PreparedStatement prepStmt =             con.prepareStatement(selectStatement);      prepStmt.setString(1, orderId);      ResultSet rs = prepStmt.executeQuery();      if (rs.next()) {         customerId = rs.getString(1);         totalPrice = rs.getDouble(2);         status = rs.getString(3);         prepStmt.close();      }      else {         prepStmt.close();         throw new NoSuchEntityException("Row for orderId " + orderId +            " not found in database.");      }   }   private void loadItems() throws SQLException {      String selectStatement =            "select itemno, productid, unitprice, quantity " +            "from  lineitems  where orderid = ? " +            "order by itemno";      PreparedStatement prepStmt =             con.prepareStatement(selectStatement);      prepStmt.setString(1, orderId);      ResultSet rs = prepStmt.executeQuery();      int count = 0;      while (rs.next()) {         int itemNo = rs.getInt(1);         String productId = rs.getString(2);         double unitPrice = rs.getDouble(3);         int quantity = rs.getInt(4);         lineItems.set(itemNo - 1,             new LineItem(productId, quantity, unitPrice, itemNo, orderId));         count++;      }      prepStmt.close();      if (count == 0) {         throw new NoSuchEntityException("No items for orderId " + orderId +            " found in database.");      }   }   private void storeOrder() throws SQLException {      String updateStatement =            "update orders set customerid =  ? ," +            "totalprice = ? , status = ? " +            "where orderid = ?";      PreparedStatement prepStmt =             con.prepareStatement(updateStatement);      prepStmt.setString(1, customerId);      prepStmt.setDouble(2, totalPrice);      prepStmt.setString(3, status);      prepStmt.setString(4, orderId);      int rowCount = prepStmt.executeUpdate();      prepStmt.close();      if (rowCount == 0) {         throw new EJBException("Storing row for orderId " +             orderId + " failed.");      }   }   private void storeItem(LineItem item) throws SQLException {      String updateStatement =            "update lineitems set productid =  ? ," +            "unitprice = ? , quantity = ? " +            "where orderid = ? and itemno = ?";      PreparedStatement prepStmt =             con.prepareStatement(updateStatement);      prepStmt.setString(1, item.getProductId());      prepStmt.setDouble(2, item.getUnitPrice());      prepStmt.setInt(3, item.getQuantity());      prepStmt.setString(4, orderId);      prepStmt.setInt(5, item.getItemNo());      int rowCount = prepStmt.executeUpdate();      prepStmt.close();      if (rowCount == 0) {         throw new EJBException("Storing itemNo " + item.getItemNo() +            "for orderId " + orderId + " failed.");      }   }} // OrderBean 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产成人av好男人在线观看| 91电影在线观看| 亚洲精品一区在线观看| 免费成人在线观看视频| 欧美一区国产二区| 久久成人精品无人区| xnxx国产精品| 成人免费高清视频在线观看| 综合中文字幕亚洲| 色噜噜狠狠成人网p站| 亚洲国产欧美一区二区三区丁香婷| 欧美亚洲图片小说| 日日欢夜夜爽一区| 久久婷婷色综合| 成人aaaa免费全部观看| 亚洲一卡二卡三卡四卡| 7777精品久久久大香线蕉 | 91精品久久久久久久91蜜桃| 日本伊人午夜精品| 久久亚洲一区二区三区四区| 成人在线视频一区| 亚洲精品乱码久久久久| 3d成人h动漫网站入口| 国产一区二区三区在线观看免费视频 | 91国在线观看| 久久精品72免费观看| 国产欧美一区视频| 一本一道综合狠狠老| 天天av天天翘天天综合网| 日韩精品专区在线影院重磅| 成人国产视频在线观看| 日韩高清欧美激情| 中文一区在线播放| 欧美卡1卡2卡| 成人黄色电影在线| 久久精品国产网站| 亚洲少妇屁股交4| 日韩欧美你懂的| 色94色欧美sute亚洲线路一久| 石原莉奈在线亚洲二区| 久久久久久电影| 欧美精品高清视频| aaa亚洲精品| 国产在线精品不卡| 亚洲国产成人porn| 中文字幕人成不卡一区| 精品91自产拍在线观看一区| 色诱视频网站一区| 国产伦理精品不卡| 蜜臀久久99精品久久久久宅男| 亚洲视频免费在线观看| 精品久久久久久无| 欧美精选午夜久久久乱码6080| 成人sese在线| 国产精品2024| 精品在线观看视频| 亚洲一区二区三区在线看 | 亚洲欧洲精品天堂一级| 欧美一区二区三区视频| 欧美在线观看视频一区二区三区| 粉嫩av一区二区三区在线播放| 久久成人久久爱| 日本午夜精品一区二区三区电影| 亚洲精品成人少妇| 中文字幕一区二区视频| 欧美激情综合在线| 国产亚洲一区二区三区| 欧美xxxxx牲另类人与| 欧美一区二区在线免费播放| 欧美吻胸吃奶大尺度电影| 91香蕉视频在线| 99久久精品免费精品国产| 国产91精品免费| 福利一区二区在线| 国产精品综合av一区二区国产馆| 久久精品国产亚洲一区二区三区| 午夜欧美大尺度福利影院在线看| 亚洲一区二区三区四区在线免费观看| 亚洲欧美自拍偷拍| 国产精品免费aⅴ片在线观看| 国产午夜精品久久久久久久 | 91亚洲资源网| 一本大道久久a久久精二百| www.欧美精品一二区| 成人午夜激情片| www.日本不卡| 欧美影视一区在线| 欧美色图第一页| 欧美一区二区在线视频| 日韩欧美一区二区视频| 欧美va亚洲va| 久久久久国产精品人| 日本一区二区三区国色天香| 国产精品免费看片| 亚洲另类色综合网站| 亚洲制服丝袜在线| 日韩福利视频网| 国产一区二区0| 97久久超碰国产精品电影| 91在线porny国产在线看| 欧美日韩精品一区二区三区蜜桃| 欧美精品v国产精品v日韩精品| 4hu四虎永久在线影院成人| 日韩欧美自拍偷拍| 国产亚洲综合性久久久影院| 亚洲人被黑人高潮完整版| 一区二区成人在线观看| 日韩成人免费电影| 国产精品综合一区二区| 91精彩视频在线| 欧美成人三级电影在线| 国产精品高潮呻吟| 午夜精品成人在线视频| 久久99国产精品成人| 成人app网站| 日韩视频不卡中文| 中文字幕精品在线不卡| 亚洲成人免费观看| 国产成人h网站| 欧美午夜精品免费| 久久综合五月天婷婷伊人| 亚洲综合小说图片| 久久99精品久久久久久国产越南| 成人福利视频在线看| 欧美男女性生活在线直播观看| 久久精品男人的天堂| 午夜免费久久看| 波多野结衣在线一区| 91.成人天堂一区| 国产精品久久久久aaaa樱花| 日本伊人色综合网| 91在线观看高清| 久久久噜噜噜久久人人看| 亚洲国产精品人人做人人爽| 高清日韩电视剧大全免费| 欧美精品日韩综合在线| 日韩理论在线观看| 麻豆成人av在线| 欧美日韩一区二区欧美激情| 欧美韩国日本综合| 蜜桃久久久久久久| 欧美性生活一区| 亚洲精品视频在线观看免费 | 免费在线成人网| 91蜜桃网址入口| 久久久久成人黄色影片| 性欧美大战久久久久久久久| 99国产精品国产精品久久| 精品国产伦理网| 奇米一区二区三区av| 在线观看不卡一区| 亚洲人成网站色在线观看| 成人午夜碰碰视频| 国产亚洲污的网站| 精品一区二区三区在线观看国产| 欧美精品欧美精品系列| 亚洲精品成人天堂一二三| 99精品在线观看视频| 国产精品国产三级国产有无不卡| 国产尤物一区二区| 精品国产一区二区三区忘忧草 | 欧美午夜影院一区| 亚洲视频狠狠干| 色婷婷av一区二区三区之一色屋| 国产精品久久久久久久久晋中| 国产精品一二一区| 精品sm在线观看| 国模一区二区三区白浆| 欧美成人激情免费网| 蓝色福利精品导航| 精品奇米国产一区二区三区| 精品在线一区二区| 久久久噜噜噜久久人人看| 国产99久久久国产精品免费看| 中文一区二区完整视频在线观看| 成人午夜激情影院| 综合久久给合久久狠狠狠97色| 不卡的av网站| 亚洲精品欧美综合四区| 色八戒一区二区三区| 亚洲国产日韩综合久久精品| 在线综合视频播放| 精品在线播放午夜| 国产亚洲1区2区3区| 福利一区二区在线观看| 亚洲欧洲国产日本综合| 欧美艳星brazzers| 蜜乳av一区二区三区| 久久久精品免费观看| 99国产精品久久久久久久久久| 一区二区三区在线免费观看 | 日韩欧美www| 成人午夜又粗又硬又大| 亚洲人成人一区二区在线观看 | 2023国产精华国产精品| 高清在线成人网| 午夜久久久久久久久久一区二区| 日韩欧美国产三级电影视频| 不卡的av中国片| 偷拍日韩校园综合在线|