public void checkSubscription() {
        PreparedStatement statement = null;
        java.util.Date current = new java.util.Date();
        openConnection();
        try {
            statement = connection.prepareStatement("SELECT subscriptionid, weekday FROM subscriptionplan");
            ResultSet res = statement.executeQuery();
            while (res.next()) {
                if (res.getInt("weekday") == current.getDay()) {
                    int subid = res.getInt("subscriptionid");
                    PreparedStatement statement2 = connection.prepareStatement("SELECT * FROM subscriptionplan WHERE subscriptionid =" + subid + " AND subscriptionid NOT IN (SELECT s.subscriptionid FROM subscriptionplan s, orders o WHERE s.subscriptionid = o.subscriptionid AND current date=o.dates)");
                    ResultSet res2 = statement2.executeQuery();
                    while (res2.next()) {
                        ArrayList<Dish> dishes = new ArrayList<Dish>();
                        PreparedStatement statement3 = connection.prepareStatement("SELECT s.dishid, d.dishname, s.dishcount, d.dishprice FROM sub_dish s, dish d WHERE s.subid = "
                                + subid + " AND s.dishid = d.dishid");
                        ResultSet res3 = statement3.executeQuery();
                        while (res3.next()) {
                            Dish newdish = new Dish(res3.getInt("dishid"), res3.getString("dishname"),
                                    res3.getInt("dishprice"), res3.getInt("dishcount"));
                            dishes.add(newdish);
                        }
                        Order order = new Order(current, res2.getString("deliveryaddress"), 7, dishes,
                                res2.getString("description"), res2.getInt("postalcode"), res2.getDouble("totalprice"));
                        PreparedStatement statement4 = connection.prepareStatement("insert into orders(timeofdelivery,"
                                + " deliveryaddress, status, usernamecustomer, subscriptionid, postalcode, dates, description, totalprice)"
                                + "values(?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
                        statement4.setTime(1, res2.getTime("timeofdelivery"));
                        statement4.setString(2, order.getDeliveryAddress());
                        statement4.setInt(3, 7);
                        statement4.setString(4, getCurrentUser());
                        statement4.setInt(5, subid);
                        statement4.setInt(6, order.getPostalcode());
                        java.sql.Date sqldate = new java.sql.Date(order.getDate().getTime());
                        statement4.setDate(7, sqldate);
                        statement4.setString(8, order.getDescription());
                        statement4.setDouble(9, order.getTotalprice());
                        statement4.executeUpdate();
                        int key = 0;
                        ResultSet res4 = statement4.getGeneratedKeys();
                        if (res4.next()) {
                            key = res4.getInt(1);
                        }

                        for (int i = 0; i < order.getOrderedDish().size(); i++) {
                            PreparedStatement statement5 = connection.prepareStatement("insert into dishes_ordered(dishid, orderid, dishcount) values(?, ?, ?)");
                            statement5.setInt(1, getDishId(order.getOrderedDish().get(i).getDishName()));
                            statement5.setInt(2, key);
                            statement5.setInt(3, order.getOrderedDish().get(i).getCount());
                            statement5.executeUpdate();
                        }
                    }
                }
            }
        } catch (SQLException e) {
            System.out.println(e);
            Cleaner.rollback(connection);

        } finally {
            Cleaner.closeSentence(statement);
            closeConnection();
        }
    }