使用Orient 3.0.3创建内存数据库

时间:2018-07-19 09:13:36

标签: java orientdb orientdb2.2

我有以下代码。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<button id="create-item">Create New Item</button>
<div id="container"></div>

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

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

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

2 个答案:

答案 0 :(得分: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();

pent悔:

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

希望有帮助。

答案 1 :(得分: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();