public int saveOrder(ArrayList<Order> order, Connection con) throws SQLException {

        int rowsInserted = 0;
        int tal = 0;
        String SQLString1 = "insert into ordre values(?,?,?)";
        String SQLString2 = "insert into ordreDetails values(?,?,?,?,?)";
        String SQLString3 = "select ordreseq.nextval from dual";



        PreparedStatement statement = null;
        for (int j = 0; j < order.size(); j++) {
            Order otest = order.get(j);

            if (otest.getOrderNo() != 0) {
                tal++;
            }
        }


        try {
            statement = con.prepareStatement(SQLString3);
            ResultSet rs = statement.executeQuery();
            if (rs.next()) {

                for (int k = tal; order.size() > k; k++) {

                    Order o = order.get(k);

                    o.setOrderNo(rs.getInt(1));
                }
            }

            statement = con.prepareStatement(SQLString1);

            for (int j = tal; j < order.size(); j++) {
                Order o = order.get(j);
                statement.setInt(1, o.getOrderNo());
                statement.setInt(2, o.getCustomer().getCustomerID());
                statement.setInt(3, o.getState());


                rowsInserted += statement.executeUpdate();
            }


            if (rowsInserted == order.size() - tal) {
                rowsInserted = 0;
                statement = con.prepareStatement(SQLString2);

                for (int i = tal; i < order.size(); i++) {
                    Order o = order.get(i);
                    for (int j = 0; j < o.getItemlist().size(); j++) {
                        statement.setInt(1, o.getItemlist().get(j).getItemNo());
                        statement.setInt(2, o.getItemlist().get(j).getItemAmount());
                        statement.setInt(3, o.getOrderNo());
                        java.sql.Date sqlDate = new java.sql.Date(o.getDepositumDate().getTime());
                        java.sql.Date sqlDate2 = new java.sql.Date(o.getorderDate().getTime());
                        statement.setDate(4, sqlDate);
                        statement.setDate(5, sqlDate2);
                        rowsInserted += statement.executeUpdate();
                    }

                }
            } else {
                System.out.println("Fejl i OrdreMapper - Part 1");
            }
        } catch (Exception e) {
            System.out.println("Fejl i OrdreMapper - SaveOrder");
            e.printStackTrace();
        }
        return order.get(order.size()-1).getOrderNo();

    }