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

[2680 byte] By [diribufa] at [2007-11-27 3:50:23]
# 1
Which database are you using?
ChristopherAngela at 2007-7-12 8:54:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
> Which database are you using?Oracle 9.
diribufa at 2007-7-12 8:54:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Can you provide a stack trace of the error? It may give other clues as to the problem.

I also initially thought of snapshot too old because they are most often seen in production where many different users are sharing Oracle memory buffers. But, I would expect that you would get a 搒napshot too old?message and not the 揈xhausted ResultSet?message so it could also be something else.

If this were my production environment I would be concerned that you are attempting to read 10 million records at a time and did not discuss it at length with the DBA (my assumption and of course you may be the DBA).The good news is there are ways to minimize the impact of batch processing on system resources using either Java or using Oracle's native utilities.Have you considered that this process could be done using Oracle native utilities rather then a Java program? If the Oracle utilities do provide the function you require you will get the added benefit of significantly reducing run time for this process.

WorkForFooda at 2007-7-12 8:54:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

I also have faced the same problem like this...

The change in the environment i.e., the Heap memory size in development and the production was different. this is because in development on our systems the heap memory might be enough to load the data into heap memory but in production server since that JVM has various other applications the heap memory available might be very less.

ShivaKatulaa at 2007-7-12 8:54:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...