Hi,
I'm currently working out to solve out the following error:
[IBM][CLI Driver] CLI0125E Function sequence error.
Searching teh web, and this same forums, I found some solutions which I did not like in particular, but anyway they didn't solve the problem.
Let me sketch the code from top of my head:
Code:
firstMethod(...) {
Connection con = Database.getConnection(); // to retrieve a connection
try {
stm = ... // New Prepared statement, a select query
rs = ... // New Resultset from the query
while( rs.next() ) {
// Does some processing
secondMethod(con);
thirdMethod(con);
}
} catch(Exception ignoredInThisExample) {
} finally {
//Properly close rs, stm (in this order), and connection itself (not needed anymore)
}
}
secondMethod(Connection con) {
//Uses the connection provided
try {
stm = ... // New Prepared statement, a select query
rs = ... // New Resultset from the query
while( rs.next() ) {
// Does some processing
}
} catch(Exception ignoredInThisExample) {
} finally {
//Properly close rs, stm (in this order), but NOT the connection itself
}
}
thirdMethod(Connection con) {
//Uses the connection provided
try {
stm = ... // New Prepared statement, a select query
rs = ... // New Resultset from the query
while( rs.next() ) {
// Does some processing
}
} catch(Exception ignoredInThisExample) {
} finally {
//Properly close rs, stm (in this order), but NOT the connection itself
}
}
Now the problem:
In the
firstMethod, it successfully executes the query, and passes through the first execution of "
while( rs.next() )".
While it is in the first record, it accesses
secondMethod and
thirdMethod with success.
On return to
firstMethod execution, it cycles the second time on "
while( rs.next() )", and throws the exception with the CLI0125E error.
So anyone has any idea why it only crashes on the second iteration? I would "understand" if it crashed inside
secondMethod, since I would be opening and cycling a second resultset with the first one still active ... but it does not crash there ...
The only idea I have is: maybe the
firstMethod rs will have a cursor, which is stored in memory (it's position). Then in the
secondMethod, I open a new rs and the cursor is reset, I completely cycle the full rs, so no error there. Same happens on
thirdMethod. Then back on
firstMethod, when it crashes on moving the cursor one position ... as if the cursor stored in memory is always the same "variable", and since the other methods changed it, it's state gets inconsistent for the rs being cycled on
firstMethod.
But then again, does this last paragraph makes any sense? Only one instance for storing the cursor position, even though I can open several resultsets? That just doesn't seem logic to me ...
Any opinions count ...
Thanks.