【发布时间】:2016-02-03 06:29:45
【问题描述】:
我创建了一个使用 neo4j 的小型 Java 应用程序。应用程序运行成功,当我打开 neo4j 管理控制台时,它没有显示数据。以下是我遵循的步骤。
MainApp.java
GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
GraphDatabaseService db = dbFactory.newEmbeddedDatabase(new File("<location>/lang.db"));
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");
db.shutdown();
System.out.println("DB Shut down");
public enum Tutorials implements Label {
JAVA,SCALA,SQL,NEO4J;
}
public enum TutorialRelationships implements RelationshipType{
JVM_LANGIAGES,NON_JVM_LANGIAGES;
}
当我运行它时,它会在 lang.db 文件夹中创建文件。 (几个文件)
然后我启动 Neo4j 社区版运行器并将路径设置为 lang.db。它成功启动了。 当我导航到http://localhost:7474/ 时,它首先要求登录(neo4j/neo4j)并更改密码。
当我查看数据库信息时,我可以看到属性键,但看不到关系类型。甚至数据库位置也配置正确。
但是当我尝试运行一些命令 MATCH (n) RETURN n LIMIT 100 它说没有行。我在这里做错了吗?
【问题讨论】: