1 Reply Latest reply: May 19, 2012 1:59 PM by greybird RSS

    cursor woes

    938426
      hello all.

      sorry for such a noob question ... but new to berkeley db je.

      i am using the base api, and have basic db creation and insertion (serialized objects) working.

      when i go to retrieve data, i can get single items just fine.

      but when i try to make a cursor, and iterate though the cursor (say with getNext())
      the first few records found seem to be ?garbage?

      if i skip over them, with something like
      int loop = 0;
      while( myCursor.getNext( key, data, LockMode.DEFAULT ) == OperationStatus.SUCCESS ){

      if( loop <= 2 ){
      loop++;
      continue;
      }


      // de-serialize here ...

      }

      then the de-serialize works great, and i am de-serializing all the items that i 'think' put 'in' (ass/u/ming i am not the one putting in the garbage).

      without the skipover i get corrupted stream errors, i think the data value is null that i am passing into the
      entryToObject().

      mmm ... couple of hints

      i am running in memory only mode.
      i open the db(s) and env.
      load the db.
      try to read the db.
      then close everything db(s), env, ect ...


      well, any hints would be greatly appreciated

      tia!

      cheers

      kjc.
        • 1. Re: cursor woes
          greybird
          Hi,

          You'll need to do a little more debugging and/or post the code that's doing the writing, serialization and deserialization.

          --mark