jeudi 7 juillet 2016

Why doesnt my main class run the method i called?

i have a question: i am trying to make an insert-query with in java using the jdbc for mysql. I think my code is correct, but somehow i can't run the method i call in my main class. Here's my method i wanna call code:

public void wijzigAfspraak() {
    try {
        Statement stmt2 = conn.createStatement();
        String query2 = "";
        rs = stmt2.executeQuery(query2);
        System.out.println("query uitgevoerd");

        while (rs.next()){
            String titel = rs.getString(1);
            String datum = rs.getString(2);
            int urgentie = rs.getInt(3);
            String beschrijving = rs.getString(4);
            System.out.println(titel+datum+urgentie+beschrijving);
    }
    }
    catch (SQLException e){
        e.printStackTrace();
    }

}

here is my main class:

public class Main {
public static void main(String[] args){

AfspraakDaoImpl adi = new AfspraakDaoImpl();
Afspraak afs = new Afspraak("","",1,"");
afs.setTitel("hond");
afs.setAfspraakDatum("12juni");
afs.setUrgentie(123);
afs.setBeschrijving("test");
adi.voegAfspraakToe();

adi.wijzigAfspraak();

}

my console doesn't print anything and my database shows no difference in data, which means it didn't work right?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire