开发者

clogin open cursors java berkeley db

开发者 https://www.devze.com 2023-04-04 18:20 出处:网络
I\'m getting this exception of opened cursos on closing some stores on berkeley db: Exception in thread \"main\" java.lang.IllegalStateException: Database still has 1 open cursors while trying to clo

I'm getting this exception of opened cursos on closing some stores on berkeley db:

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:462)
    at com.sleepycat.je.Database.close(Database.java:314)
    at com.sleepycat.persist.impl.Store.closeDb(Store.java:1449)
    at com.sleepycat.persist.impl.Store.close(Store.java:1058)
    at com.sleepycat.persist.EntityStore.close(EntityStore.java:626)

This error occours "on myStore.close()":

public void close() throws DatabaseException {
    myStore.close();
    myDB.close();
    env.close();
}

But I didn't manually open any cursor.

I've looked for this error, and I didn't find anything special I'd had to do (because I didn't open the cursor manually).

So I think I did something wrong on opening the database. What I do on opening the store:

myStore = new EntityStore(env, "StoreTest", storeConfig);
PrimaryIndex<Long, MYClass> myPrimaryIndex = myStore.getPrimaryIndex(Long.class, MyClass.class);

Again开发者_JAVA百科: I didn't manually open any cursor.


Any call to EntityIndex.entities() opens a cursor, whether you assign it to a variable or not. So make sure, that you assign it to an EntityCursor object, and call it's close() method afterwards, like this:

EntityCursor<Employee> cursor = primaryIndex.entities();
try {
         ...
} finally {
    cursor.close();
}

I have had a similar problem, and this was the solution, also posted on OTN forums here: https://forums.oracle.com/forums/thread.jspa?messageID=10241239

0

精彩评论

暂无评论...
验证码 换一张
取 消