⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ordertrackingintf_impl.java

📁 AdventureBuilder JSF
💻 JAVA
字号:
package orderservice;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import javax.naming.InitialContext;import javax.naming.NamingException;import javax.sql.*;/** * This is the implementation bean class for the OrderTracking web service. * Created Dec 1, 2005 3:02:17 PM * @author admin */public class OrderTrackingIntf_Impl implements orderservice.OrderTrackingIntf, java.rmi.Remote {    public orderservice.OrderDetails getOrderDetails(java.lang.String orderId) throws            orderservice.OrderNotFoundException,  java.rmi.RemoteException {        orderservice.OrderDetails orderdetails = new orderservice.OrderDetails();        Connection connection = null;        PreparedStatement preparedStatement=null;        String contactInfoBeanBilling=null;        String contactInfoBeanShipping=null;        String creditCardBean=null;        String addressBean=null;        Address addressBilling = new Address();        Address addressShipping = new Address();        ContactInfo contactInfoBilling = new ContactInfo();        ContactInfo contactInfoShipping = new ContactInfo();        CreditCard creditCard = new orderservice.CreditCard();                        try{            connection = getConnection();        } catch(Exception ne) {            System.out.println("Caught Exception");            ne.printStackTrace();        }                try{                        preparedStatement=connection.prepareStatement("SELECT * FROM ADVENTUREBUILDER.PURCHASEORDERBEAN where ADVENTUREBUILDER.PURCHASEORDERBEAN.POID = ? ");            preparedStatement.setString(1, orderId);            ResultSet resultSet=preparedStatement.executeQuery();            orderservice.PurchaseOrder po = new orderservice.PurchaseOrder();                        while(resultSet.next()) {                po.setTotalPrice(resultSet.getFloat("TOTALPRICE"));                java.util.Calendar calendarStartDate = java.util.Calendar.getInstance();                calendarStartDate.setTimeInMillis(resultSet.getLong("STARTDATE"));                po.setStartDate(calendarStartDate);                po.setUserId(resultSet.getString("USERID"));                po.setDepartureCity(resultSet.getString("DEPARTURECITY"));                java.util.Calendar calendarOrderDate = java.util.Calendar.getInstance();                calendarOrderDate.setTimeInMillis(resultSet.getLong("ORDERDATE"));                po.setOrderDate(calendarOrderDate);                java.util.Calendar calendarEndDate = java.util.Calendar.getInstance();                calendarEndDate.setTimeInMillis(resultSet.getLong("ENDDATE"));                po.setOrderDate(calendarEndDate);                po.setHeadCount(resultSet.getInt("HEADCOUNT"));                po.setEmailId(resultSet.getString("EMAILID"));                po.setActivityPrice(resultSet.getFloat("ACTIVITYPRICE"));                po.setLodgingPrice(resultSet.getFloat("LODGINGPRICE"));                po.setTransportationPrice(resultSet.getFloat("TRANSPORTATIONPRICE"));                contactInfoBeanBilling=resultSet.getString("CONTACTINFOBEAN_GENERATEDPKFIELD");                contactInfoBeanShipping=resultSet.getString("CONTACTINFOBEAN_GENERATEDPKFIELD96");                creditCardBean=resultSet.getString("CREDITCARDBEAN_GENERATEDPKFIELD");                            }                                                preparedStatement=connection.prepareStatement("SELECT * FROM ADVENTUREBUILDER.CONTACTINFOBEAN where ADVENTUREBUILDER.CONTACTINFOBEAN.GENERATEDPKFIELD = ? ");            preparedStatement.setString(1, contactInfoBeanBilling);            resultSet=preparedStatement.executeQuery();            while(resultSet.next()){                contactInfoBilling.setPhone(resultSet.getString("PHONE"));                contactInfoBilling.setEmail(resultSet.getString("EMAIL"));                contactInfoBilling.setGivenName(resultSet.getString("GIVENNAME"));                contactInfoBilling.setFamilyName(resultSet.getString("FAMILYNAME"));                addressBean = resultSet.getString("ADDRESSBEAN_GENERATEDPKFIELD");            }                                    preparedStatement=connection.prepareStatement("SELECT * FROM ADVENTUREBUILDER.ADDRESSBEAN where ADVENTUREBUILDER.ADDRESSBEAN.GENERATEDPKFIELD = ? ");            preparedStatement.setString(1, addressBean);            resultSet=preparedStatement.executeQuery();                        while(resultSet.next()){                addressBilling.setPostalCode(resultSet.getString("PostalCode"));                addressBilling.setStreetName1(resultSet.getString("STREETNAME1"));                addressBilling.setStreetName2(resultSet.getString("STREETNAME2"));                addressBilling.setCity(resultSet.getString("CITY"));                addressBilling.setState(resultSet.getString("STATE"));                addressBilling.setCountry(resultSet.getString("COUNTRY9"));                                            }            contactInfoBilling.setAddress(addressBilling);            po.setBillingInfo(contactInfoBilling);                        preparedStatement=connection.prepareStatement("SELECT * FROM ADVENTUREBUILDER.CONTACTINFOBEAN where ADVENTUREBUILDER.CONTACTINFOBEAN.GENERATEDPKFIELD = ? ");            preparedStatement.setString(1, contactInfoBeanShipping);            resultSet=preparedStatement.executeQuery();                        while(resultSet.next()){                contactInfoShipping.setPhone(resultSet.getString("PHONE"));                contactInfoShipping.setEmail(resultSet.getString("EMAIL"));                contactInfoShipping.setGivenName(resultSet.getString("GIVENNAME"));                contactInfoShipping.setFamilyName(resultSet.getString("FAMILYNAME"));                addressBean = resultSet.getString("ADDRESSBEAN_GENERATEDPKFIELD");            }            //----            preparedStatement=connection.prepareStatement("SELECT * FROM ADVENTUREBUILDER.ADDRESSBEAN where ADVENTUREBUILDER.ADDRESSBEAN.GENERATEDPKFIELD = ? ");            preparedStatement.setString(1, addressBean);            resultSet=preparedStatement.executeQuery();                        while(resultSet.next()){                addressShipping.setPostalCode(resultSet.getString("PostalCode"));                addressShipping.setStreetName1(resultSet.getString("STREETNAME1"));                addressShipping.setStreetName2(resultSet.getString("STREETNAME2"));                addressShipping.setCity(resultSet.getString("CITY"));                addressShipping.setState(resultSet.getString("STATE"));                addressShipping.setCountry(resultSet.getString("COUNTRY9"));                            }            contactInfoShipping.setAddress(addressShipping);            po.setShippingInfo(contactInfoShipping);                        preparedStatement=connection.prepareStatement("SELECT * FROM ADVENTUREBUILDER.CREDITCARDBEAN where ADVENTUREBUILDER.CREDITCARDBEAN.GENERATEDPKFIELD = ? ");            preparedStatement.setString(1, creditCardBean);            resultSet=preparedStatement.executeQuery();                        while(resultSet.next()){                creditCard.setCardNumber(resultSet.getString("CARDNUMBER"));                creditCard.setCardType(resultSet.getString("CARDTYPE"));                creditCard.setCardExpiryDate(resultSet.getString("CARDExpiryDate"));            }            po.setCreditCard(creditCard);                        //update status of po in database            preparedStatement=connection.prepareStatement("UPDATE ADVENTUREBUILDER.PURCHASEORDERBEAN SET ADVENTUREBUILDER.PURCHASEORDERBEAN.STATUS = ? WHERE ADVENTUREBUILDER.PURCHASEORDERBEAN.POID = ? ");            preparedStatement.setString(1, "SUBMITTED TO SUPPLIER FOR PROCESSING");            preparedStatement.setString(2, orderId);            preparedStatement.executeUpdate();                        //this is stubbed            po.setStatus("In Process");            orderdetails.setPO(po);                    } catch(SQLException e) {            System.out.println("Caught an SQLException");            e.printStackTrace();        } finally{            close(preparedStatement,connection);        }                return orderdetails;    }            private static Connection getConnection() throws NamingException,SQLException {                Connection conn = null;        try{                        InitialContext context=new InitialContext();            DataSource datasource=(javax.sql.DataSource)context.lookup("jdbc/AdventureBuilder");            conn=datasource.getConnection();        }catch (NamingException ne) {            System.out.println("Caught NamingException");            ne.printStackTrace();                    }catch (SQLException sqle){            System.out.println("Caught SQLException");            sqle.printStackTrace();        }        return conn;            }//getConnection        private void close(PreparedStatement Statement ,Connection connection){        try{            Statement.close();            connection.close();        } catch(SQLException e){            System.out.println("Caught an SQLException");            e.printStackTrace();        }    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -