• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java JDBC : db2java.zip : [IBM][CLI Driver] CLI0125E Function sequence error.

b4u

Golden Member
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.

I sketched the code structure from top of my head.


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.
 
Code got all messed up ... here it is:

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
}

}
 
Would it be possible for you to just open a new database connection in the second and third methods instead of passing it? At first glance it sounds a little like a scope problem, where when you do the rs.next it no longer knows what rs is.
 
Back
Top