@@ -0,0 +1,3521 @@
+package Entity;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.Date;%0Aimport java.sql.DriverManager;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0Aimport java.text.SimpleDateFormat;%0A%0A/**%0A *%0A * @author peter%0A */%0Apublic class ConfirmOrder %7B%0A%0A    String result = %22OK%22;%0A    String session;%0A    String time = null;%0A    String customer;%0A    String pizzaOrder;%0A    int quantity;%0A%0A    %0A    public ConfirmOrder(String session_id) %7B%0A        // take values from basket table and place in order table%0A        session = session_id;%0A        %0A    %7D%0A    %0A    public ConfirmOrder(String session_id, String time) %7B%0A        // take values from basket table and place in order table%0A%0A        time = time;%0A        session = session_id;%0A        String timeStamp = new SimpleDateFormat(%22yyyy-MM-dd HH:mm:ss%22).format(new Date(System.currentTimeMillis()+10*60*1000)); // now + 10 mins%0A        String requestedDate = ((time == null) ? timeStamp : time );  // assign a time if one is not passed in%0A        %0A    %7D%0A    %0A    //Object add(Integer session_id, String time) throws SQLException %7B%0A    public Object add() throws SQLException %7B%0A        // writes into BASKET table the provisional order including session_id (used to find order in DB and confirm it at checkout)%0A        String dbURL = %22jdbc:derby://localhost:1527//home/peter/pizzabase%22;%0A        String tableName1 = %22basket%22;%0A        String tableName2 = %22orders%22;%0A%0A        // jdbc Connection%0A        Connection conn = null;%0A        Statement stmtRead = null;%0A        Statement stmtWrite = null;%0A        Statement stmtDelete = null;%0A        %0A        String result = %22OK%22;%0A        %0A        try%0A        %7B%0A            Class.forName(%22org.apache.derby.jdbc.ClientDriver%22).newInstance();%0A            //Get a connection%0A            conn = DriverManager.getConnection(dbURL); %0A        %7D%0A        catch (ClassNotFoundException cnfe) %7B%0A            System.err.println(%22Derby driver not found.%22);%0A        %7D%0A        catch (InstantiationException %7C IllegalAccessException %7C SQLException except)%0A        %7B%0A            except.printStackTrace();%0A        %7D%0A%0A        stmtRead = conn.createStatement();%0A        ResultSet results = stmtRead.executeQuery(%22select customer, pizzaorder, quantity from %22 + tableName1 + %22 where session = %22+ session);%0A        stmtWrite = conn.createStatement();%0A%0A        while(results.next())%0A        %7B%0A            customer = results.getString(1);%0A            pizzaOrder = results.getString(2);%0A            quantity = results.getInt(3);%0A%0A            stmtWrite.execute(%22insert into %22 + tableName2 + %22 values ('%22 + customer + %22','%22 + pizzaOrder + %22',%22 + quantity + %22, TIMESTAMP('%22 + time +%22'))%22);%0A        %7D%0A        results.close();%0A        stmtRead.close();%0A        stmtWrite.close();%0A        stmtDelete = conn.createStatement();%0A        stmtDelete.execute(%22delete from %22 + tableName1 + %22 where session = %22+ session);%0A%0A        try%0A        %7B%0A            if (stmtRead != null)%0A            %7B%0A                stmtRead.close();%0A            %7D%0A            if (stmtWrite != null)%0A            %7B%0A                stmtWrite.close();%0A            %7D%0A                        if (stmtDelete != null)%0A            %7B%0A                stmtDelete.close();%0A            %7D%0A%0A            if (conn != null)%0A            %7B%0A                DriverManager.getConnection(dbURL);%0A                conn.close();%0A            %7D           %0A        %7D%0A        catch (SQLException sql)%0A        %7B%0A            sql.printStackTrace();%0A        %7D%0A    return result;%0A    %7D%0A%7D%0A    %0A    %0A        %0A    %0A    %0A

Create ConfirmOrder.java