简体   繁体   English

OrientDB:找不到符号OGraphDatabase

[英]OrientDB : Can't find symbol OGraphDatabase

I searched some examples on the Internet and many of them use the OGraphDatabase. 我在互联网上搜索了一些例子,其中很多都使用了OGraphDatabase。 However, when these code file was compiled, a exception that says cant find the symbol of "OGraphDatabase" was throwed. 但是,当编译这些代码文件时,抛出了一个无法找到“OGraphDatabase”符号的异常。 Blow is the source code: Blow是源代码:

public class TestTreeGraph {
static OGraphDatabase db;
//static int i=0;
//static ODocument currentNode;

public static void main(String[] args) throws FileNotFoundException{
    String dbpath="/Users/wuguirongsg/orientdb/orientdbgraph";
    File dbfile = new File(dbpath);

    if(!dbfile.exists()){
        //dbfile.mkdirs();
        db = new OGraphDatabase("local:"+dbpath).create();
        db = new OGraphDatabase("local:"+dbpath).open("admin", "admin");
    }else{
        db = new OGraphDatabase("local:"+dbpath).open("admin", "admin");
    }

    ODocument rootNode = db.createVertex().field("id", 0);
    int i=1;
    createNode(rootNode,i);

    db.setRoot("treegraph", rootNode);
}

private static void createNode(ODocument node,int i){
    if(i>=20){
        System.out.println("i>=10================== back ");
        return ;
    }
    ODocument leftNode = db.createVertex().field("id", i + "_vertex_left");
    System.out.println("create "+i + "_vertex_left ");
    ODocument rightNode = db.createVertex().field("id", i + "_vertex_right");
    System.out.println("create "+i + "_vertex_right ");
    ODocument edgeleft = db.createEdge( node, leftNode);
    ODocument edgeright = db.createEdge( node, rightNode);
    edgeleft.save();
    edgeright.save();
    //currentNode = leftNode;
    System.out.println("go left");
    createNode(leftNode,i+1);
    System.out.println("go right");
    createNode(rightNode,i+1);
    System.out.println("==================");
}

} }

OGraphDatabase has been deprecated ages ago. OGraphDatabase很久以前就已被弃用。 You can use OrientGraph. 你可以使用OrientGraph。

Example

String dbpath="C:/test";
OrientGraphFactory factory = new OrientGraphFactory("plocal:"+dbpath);

// if the database doesn't exist it is created and opened
// if the database exists, it is opened
OrientGraph db = factory.getTx();

// inserting a vertex
Vertex rootNode=db.addVertex("class:V");
rootNode.setProperty("myId","0");

db.shutdown();

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM