Unexpected "Exhausted Resultset" exception
I have a code that does a query in a database, iterates thru the resultset and write the results to a file. I tested it a lot on my development environment, even with large results (such as 10 million records) and it always worked fine.
But when I promoted to production it never worked and it gives me "Exhausted Resultset", which as far as I know, occurs when u execute a read method on a Resultset in which next() returned false, right?
At production, the table read get updated A LOT, and the query returns something like 7.5 millions records. Could it be some kind of "old snapshot" fault that is making the resultset to become unexpectedly "finished"?
Bellow is the code used:
rs = spaceConn.executeQuery( sql, arquivoLog,null );
if( rs.next() ){
loteAnt = lote = rs.getString(1);
serialIni = serial = rs.getString(2);
statusAnt = status = rs.getString(3);
valor = rs.getString(4);
}else{
thrownew RuntimeException("No data found");
}
do{
if( numLinhas == linhasQuebra ){// quebrar, fechar arquivo e abrir outro.
// do some result-processing, file-writing. No code dealing with the ResultSet here.
}
lote = rs.getString(1);
serial = rs.getString(2);
status = rs.getString(3);
valor = rs.getString(4);
// determina a quebra
if( !lote.equals(loteAnt) || !status.equals(statusAnt) ){
// more file-writing and processing, no Resultset codes
}
loteAnt = lote;
statusAnt = status;
serialFim = serial;
valorLote = valor;
statusLote = status;
totalLinhas++;
}while ( rs.next() );// do
arquivoSaida.println( serialIni +";" + serialFim +";" + statusLote +";" + valorLote );
The exception occurs within this do-while loop.
Any clues?
Thanks

