Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OrientDB:Can';找不到符号数据库_Orientdb - Fatal编程技术网

OrientDB:Can';找不到符号数据库

OrientDB:Can';找不到符号数据库,orientdb,Orientdb,我在网上搜索了一些例子,其中很多都使用了数据库。然而,在编译这些代码文件时,抛出了一个异常,即找不到“OGraphDatabase”的符号。 以下是源代码: public class TestTreeGraph { static OGraphDatabase db; //static int i=0; //static ODocument currentNode; public static void main(String[] args) throws FileNotFoundExcepti

我在网上搜索了一些例子,其中很多都使用了数据库。然而,在编译这些代码文件时,抛出了一个异常,即找不到“OGraphDatabase”的符号。 以下是源代码:

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("==================");
}

}

早就不推荐使用该数据库了。您可以使用OrientGraph

范例

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();

早就不推荐使用该数据库了。您可以使用OrientGraph

范例

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();

Hi Qinger,您使用的是哪个版本的OrientDB?Hi Qinger,您使用的是哪个版本的OrientDB?