If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Java JDBC : db2java.zip : [IBM][CLI Driver] CLI0125E Function sequence error.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-27-07, 18:07
zecas zecas is offline
Registered User
 
Join Date: Jun 2007
Posts: 1
Question Java JDBC : db2java.zip : [IBM][CLI Driver] CLI0125E Function sequence error.

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.
Reply With Quote
  #2 (permalink)  
Old 06-29-07, 03:31
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
My guess is that you do something is "secondMethod" that relies on transaction context or so. You didn't tell us what those methods are doing, so it's hard to say anything more specific.

The first thing you should always do in CLI/JDBC applications is to turn off auto-commit. (The second this is to turn of the default that cursors are holdable.)
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On