Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2007
    Posts
    1

    Question Unanswered: 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.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •