public void runQuery() {
        
        // gets search parameters from searchpanel
        
        ArrayList<String> ingred = new ArrayList();
        String str = searchpanel.getIngredients().getText();
        String[] ingreds = str.split(" ");
        for (int i = 0; i < ingreds.length; i++) {
            ingred.add(ingreds[i]);
        }
        
        int strtime = Integer.parseInt(searchpanel.getTime().getText());
        int peopleamount = Integer.parseInt(searchpanel.getAmountOfPeople().getText());
        String isvege = searchpanel.getVege().getText();
        
        //sets text fields as empty after search button is pressed
        
        searchpanel.getVege().setText("");
        searchpanel.getIngredients().setText("");
        searchpanel.getTime().setText("");
        searchpanel.getAmountOfPeople().setText("");

        System.out.println("Resepti:");
        
        //sets parameters for query
        db.timeInMins(strtime);
        db.setIngredients(ingred);
        db.setAmountOfPeople(peopleamount);

        try {
            //database run method executes query
            db.run();
            
            
            
            //gets results of query and sets into arraylist tiedot
            ArrayList<String> tiedot = db.haeTiedot();
            System.out.println(db.haeTiedot());
            
            //if query returns something start parsing
            if (tiedot.size() >= 0) {
                name.setText("" + tiedot.get(1) + "");
                System.out.println("Nimi: " + tiedot.get(1));
                
                //set preparationtime for resultspanel
                preptime.setText("Valmistusaika: " + tiedot.get(0) + " min");
                System.out.println("Valmistusaika: " + tiedot.get(0) + " min");
                
                
                //set ingredients for resultspanel
                System.out.println("Ainekset: " + tiedot.get(2));
                String[] ingredientarray = parseOutputIngredients(tiedot.get(2));
                String ainekset = "";
                for (String item : ingredientarray) {
                    ainekset += (item + "\n");
                }
                resultspanel.setOutputIngreds(ainekset);
                
                
                //set instructions for resultspanel
                System.out.println("Valmistusohjeet: \n" + tiedot.get(3));
                String[] instructionarray = parseOutputInstructions(tiedot.get(3));
                String ohje = "";
                for (String ins : instructionarray) {
                    if (ins.length() > 0) {
                        ohje += (ins + "\n");
                    }
                }
                resultspanel.setOutputInstructs(ohje);

            }

        } catch (InstantiationException ex) {
            Logger.getLogger(BasicSwing.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(BasicSwing.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(BasicSwing.class.getName()).log(Level.SEVERE, null, ex);
        }
    }