0

我有以下代码。

String orientDBPath = "memory:visdb";
ODatabaseObjectPool objectPool;
OrientDBConfig dbConfig = OrientDBConfig.defaultConfig();
objectPool = new ODatabaseObjectPool(orientDBPath, username, password, dbConfig);

当我使用 objectPool.acquire() 获取 ODatabaseObject 时,我收到以下 ODatabaseException。

Caused by: com.orientechnologies.orient.core.exception.ODatabaseException: OrientDB instanced created without physical path, only memory databases are allowed
    DB name="visdb"
    at com.orientechnologies.orient.core.db.OrientDBEmbedded.buildName(OrientDBEmbedded.java:186)
    at com.orientechnologies.orient.core.db.OrientDBEmbedded.getOrInitStorage(OrientDBEmbedded.java:173)
    at com.orientechnologies.orient.core.db.OrientDBEmbedded.poolOpen(OrientDBEmbedded.java:159)
    at com.orientechnologies.orient.core.db.ODatabasePoolImpl$1.createNewResource(ODatabasePoolImpl.java:40)
    at com.orientechnologies.orient.core.db.ODatabasePoolImpl$1.createNewResource(ODatabasePoolImpl.java:37)
    at com.orientechnologies.common.concur.resource.OResourcePool.getResource(OResourcePool.java:95)
    at com.orientechnologies.orient.core.db.ODatabasePoolImpl.acquire(ODatabasePoolImpl.java:59)
    at com.orientechnologies.orient.core.db.ODatabasePool.acquire(ODatabasePool.java:132)
    at com.orientechnologies.orient.object.db.ODatabaseObjectPool.acquire(ODatabaseObjectPool.java:40)

为内存数据库初始化 ODatabaseObjectPool 和 ODatabasePool 的正确方法是什么?

4

2 回答 2

0

我找到了另一个对我有用的解决方案。

OrientDBConfig dbConfig = OrientDBConfig.defaultConfig();
ODatabasePoolInternal documentPoolInternal;

OrientDBEmbedded orientDBEmbedded = new OrientDBEmbedded("", dbConfig, Orient.instance());

orientDBEmbedded.create(orientDBName, username, password, ODatabaseType.MEMORY, dbConfig);

documentPoolInternal = orientDBEmbedded.openPool(orientDBName, username, password);

ODatabaseSession session = documentPoolInternal.acquire();
于 2018-07-23T08:56:37.017 回答
0

我确实在我的单元测试中使用内存图。这是我创建池的方式

    String orientDBPath = "memory:visdb";
    OrientDBConfig dbConfig = OrientDBConfig.defaultConfig();

    OrientDB orientDB = new OrientDB(orientDBPath, dbConfig);
    orientDB.createIfNotExists(orientDBPath, ODatabaseType.MEMORY);
    ODatabasePool pool = new ODatabasePool(orientDB, orientDBPath, "admin",
            "admin");
    ODatabaseSession session = pool.acquire();

    // later
    session.close();
    pool.close();
    orientDB.close();

依赖:

    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-client</artifactId>
        <version>3.0.4</version>
    </dependency>

希望能帮助到你。

于 2018-07-21T00:16:55.263 回答