[英]Neo4j embedded graph java visualization
I'm beginning in Neo4j java embedded graph.我从 Neo4j java 嵌入式图开始。 I have made a first test but I cant visualize my graph in neo4j-community.
我已经进行了第一次测试,但我无法在 neo4j-community 中可视化我的图表。
Here is my code for creating the graph :这是我创建图形的代码:
package connection;
import java.io.File;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
public class embededdedGraph {
public static void main(String... args) throws Exception {
GraphDatabaseFactory graphDbFactory = new GraphDatabaseFactory();
File graphDir = new File("/home/nicolas/neo4j-community-3.5.14/data/databases/cars.db");
GraphDatabaseService graphDb = graphDbFactory.newEmbeddedDatabase(graphDir);
Transaction tx = graphDb.beginTx();
createNode(graphDb);
tx.close();
}
public static void createNode(GraphDatabaseService graphDb) {
Node car = graphDb.createNode();
car.addLabel(Label.label("Car"));
car.setProperty("make", "tesla");
car.setProperty("model", "model3");
Node owner = graphDb.createNode(Label.label("Person"));
owner.setProperty("firstName", "Oliver");
owner.setProperty("lastName", "John");
owner.createRelationshipTo(car, RelationshipType.withName("owner"));
}
}
Next I changed the value of "#dbms.active_database"
to "dbms.active_database=cars.db
in the /neo4j-community-3.5.14/conf/neo4.conf
file.接下来,我将
/neo4j-community-3.5.14/conf/neo4.conf
文件中的"#dbms.active_database"
的值更改为"dbms.active_database=cars.db
。
When I restart the neo4j-community, the database name is "cars.db" but it indicated that there are no labels and relationships in it.当我重新启动neo4j-community 时,数据库名称是“cars.db”,但它表明其中没有标签和关系。
What is the problem I cannot figure?我想不通的问题是什么?
Nicolas尼古拉斯
It looks like you need to call tx.success() or tx.fail() before tx.close().看起来您需要在 tx.close() 之前调用 tx.success() 或 tx.fail()。
https://neo4j.com/docs/java-reference/3.5/javadocs/org/neo4j/graphdb/Transaction.html https://neo4j.com/docs/java-reference/3.5/javadocs/org/neo4j/graphdb/Transaction.html
I am also new at this API, I hope it helps我也是这个 API 的新手,希望对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.