I want to end this Do While loop if the the pulls are 0 or the time is on 60 sek.
But if the pulls are at 0 the loop doesn't stop.
do{
try
{
Thread.sleep(1000);
sek++;
System.out.println(sek);
}
catch(Exception e)
{
System.out.println(e);
}
db = new BdsPostgres( );
db.select(Result.SET_1, "SELECT * FROM connection_overview WHERE leitung="+leitung+" AND status='pull' ");
db.naechsterDatensatz(Result.SET_1);
anzahlPulls = db.leseZeilen(Result.SET_1);
db.schliessen();
} while (anzahlPulls != 0 || sek != 60);
You want to use
andinstead ofor, please note inwhileloop if the condition evaluates to true, it continues the loop, does not end it.So actually your condition reads as - while either (anzahlPulls is not zero) or (sek is not 60) continue the loop. (that is when one of the condition is true continue the loop)
You actually want to use
and- while both (anzajlPulls is not zero) and (sek is not 60) continue the loop. (that is break the loop when one of the conditions becomes false)Example code -