1

我正在尝试使用orientdb。示例非常简单:

package models;

import java.util.List;

import com.orientechnologies.orient.core.db.object.ODatabaseObjectPool;
import com.orientechnologies.orient.core.db.object.ODatabaseObjectTx;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;

public class User {

    public String name;

    public static void main(String[] args) {
        String uri = "local:c:\\orientdb";

        ODatabaseObjectTx db = ODatabaseObjectPool.global().acquire(uri, "admin", "admin");
        db.getEntityManager().registerEntityClass(User.class);

        User user = new User();
        user.name = "aaa";
        db.save(user);

        List<?> list = db.query(new OSQLSynchQuery<Long>("select count(*) from User"));
        System.out.println(list);
        db.commit();
        db.close(); // ****** throws exception
    }
}

但是最后一行db.close()会抛出异常:

Exception in thread "main" com.orientechnologies.common.concur.lock.OLockException: Can't release a database URL not acquired before. URL: c:\orientdb
    at com.orientechnologies.orient.core.db.ODatabasePoolAbstract.release(ODatabasePoolAbstract.java:81)
    at com.orientechnologies.orient.core.db.ODatabasePoolBase.release(ODatabasePoolBase.java:43)
    at com.orientechnologies.orient.core.db.object.ODatabaseObjectTxPooled.close(ODatabaseObjectTxPooled.java:81)
    at models.User.main(User.java:26)

哪里错了?

4

1 回答 1

5

最后发现是Orientdb的一个bug。它无法正确处理 Windows 路径,并且无法提供良好的错误消息。

如果我使用local:c:/orientdbnot local:c:\orientdb,一切都很好。

我已将此报告给 orientdb 团队。

于 2011-05-06T06:33:54.670 回答