使用JavaAPI插入数据后无法连接远程oriendb

时间:2016-11-06 16:27:35

标签: java linux database orientdb java-api

我知道有关于这个主题的问题,我在Closing a "local" OrientDB when using connection pools找到了。 但它无法解决我的问题,即: 我有代码

OrientGraphFactory ogf = new OrientGraphFactory("plocal:/opt/orientdb/databases/sad", "admin", "admin");
    if(ogf.exists()){
        System.out.println("Database exist");
    }
    else
        System.out.println("Database NOT exist");

    OrientGraph og = ogf.getTx();
    Vertex vPerson = og.addVertex("class:My");
    vPerson.setProperty("city", "Almaty");
    vPerson.setProperty("city", "Astana");
    System.out.println(og.countVertices());
    OGlobalConfiguration.STORAGE_KEEP_OPEN.setValue( false );
    og.shutdown();
    ogf.close();

此后当我尝试通过console.sh与命令

连接时
connect remote:localhost/sad root root

无法连接到错误的数据库:

Error: com.orientechnologies.orient.core.exception.OStorageException: Cannot open local storage '/opt/orientdb/databases/sad' with mode=rw

Error: com.orientechnologies.orient.core.exception.OSerializationException: Cannot load database's configuration. The database seems to be corrupted.

我还在orientdb-server-config.xml中添加了2行:

<properties>
        <entry value="1" name="db.pool.min"/>
        <entry value="50" name="db.pool.max"/>
        <entry value="true" name="profiler.enabled"/>
        <entry value="info" name="log.console.level"/>
        <entry value="fine" name="log.file.level"/>
        + <entry name="cache.size" value="10000" />
        + <entry name="storage.keepOpen" value="false" />
    </properties>

请帮助我。

1 个答案:

答案 0 :(得分:1)

我尝试使用2.2.12版本的代码,我只改变了我的路径

OrientGraphFactory ogf = new OrientGraphFactory("plocal:mypath/orientdb-community-2.2.12/databases/sad", "admin", "admin");

在我启动服务器之后,从控制台我与数据库连接。

enter image description here

希望它有所帮助。