我是neo4j的新手。我在Eclipse中创建了一个java
项目来创建一个neo4j
数据库及其中的一些节点。我看到在我的工作区文件夹中创建了数据库目录。但是我如何在neo4j浏览器上查看它?
以下是我使用的示例代码:
package com.neo4j.demo;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
public class Neo4jDemoOperations {
public static void main(String args[]) {
GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
GraphDatabaseService db = dbFactory.newEmbeddedDatabase("./DemoDatabase");
try (Transaction tx = db.beginTx()) {
Node javaNode = db.createNode(Tutorials.JAVA);
javaNode.setProperty("TutorialID", "JAVA001");
javaNode.setProperty("Title", "Learn Java");
javaNode.setProperty("NoOfChapters", "25");
javaNode.setProperty("Status", "Completed");
Node scalaNode = db.createNode(Tutorials.SCALA);
scalaNode.setProperty("TutorialID", "SCALA001");
scalaNode.setProperty("Title", "Learn Scala");
scalaNode.setProperty("NoOfChapters", "20");
scalaNode.setProperty("Status", "Completed");
Relationship relationship = javaNode.createRelationshipTo(
scalaNode, TutorialRelationships.JVM_LANGIAGES);
relationship.setProperty("Id", "1234");
relationship.setProperty("OOPS", "YES");
relationship.setProperty("FP", "YES");
tx.success();
}
System.out.println("Done successfully");
}
}
Tutorials
和TutorialRelationships
是枚举。
提前致谢。
答案 0 :(得分:1)
我在行
中更改了数据库的路径org.neo4j.server.database.location=
在neo4j-server.properties
文件夹内的conf
文件中。我在workspace
文件夹中选择了路径作为数据库的路径,并且它有效!