1 Reply Latest reply: May 5, 2012 8:52 AM by 935209 RSS


      hello, recently I use berkerly DB JE to write a small test, but I get the IndexOutOfBoundsException, could anyone help ? thanks!
      here is part of the code:
      /*put data*/
      DatabaseEntry theKey = new DatabaseEntry(stemp.getBytes("UTF-8"));
                     DatabaseEntry theData = new DatabaseEntry(path.getName().getBytes("UTF-8"));
                     OperationStatus status = db.put(null, theKey, theData);

      /* retrieve the data */
      DatabaseEntry keyEntry = new DatabaseEntry();
      DatabaseEntry dataEntry = new DatabaseEntry();

      Cursor cursor = db.openCursor(null, null);

      int it = 0;
      ArrayList<DatabaseEntry> keyArray = new ArrayList<DatabaseEntry>();
      while (cursor.getNext(keyEntry, dataEntry, LockMode.DEFAULT) ==
      OperationStatus.SUCCESS) {
      System.out.println("key=" +
      IntegerBinding.entryToInt(keyEntry) +
      " data=" +

      the error is below:
      Exception in thread "main" java.lang.IllegalStateException: Database still has 1 open cursors while trying to close.
           at com.sleepycat.je.Database.closeInternal(Database.java:503)
           at com.sleepycat.je.Database.close(Database.java:348)
           at hello.HelloDatabaseWorld.close(HelloDatabaseWorld.java:147)
           at hello.HelloDatabaseWorld.main(HelloDatabaseWorld.java:98)
      but I debug and find the main reason the process close the database is an IndexOutOfboundException caused by IntegerBinding.entryToInt(dataEntry) ,I don't know why and if I try to change the IntegerBinding.entryToInt(dataEntry) to StringBinding.entryToString(dataEntry), it also throws the ArrayIndexOutOfBoundException or IndexOutOfboundException(sorry I dont remember which one cleary).

      Could anyone help me? Thanks a lot!!