2 Replies Latest reply: May 1, 2012 9:10 AM by 850455 RSS

    Traverse all rows of database for migration script

    850455
      I am trying to write a custom migration script in java and I simply want to retrieve all rows from the database. I would think this would be simple but it is not working as I expected. I am trying to do it with a cursor looping while cursor.getNext is not null. This throws me in an infinite loop and doesn't seem to be stepping to the next record at all. code snippet

      Cursor cursor = db.openCursor(null, null);
      DatabaseEntry data = new DatabaseEntry();
      DatabaseEntry key = new DatabaseEntry();

      while(cursor.getNext(key, data, null) != null){
           TupleInput returnData = TupleBinding.entryToInput(data);
           log.info("row: " + returnData.readString());
      }
      cursor.close();