Reputation: 17
I am trying to create a new node in the neo4j database graph.db using java, I am trying to execute this code:
GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase("./users/rih/neo4j-2.2.5/data/graph.db");
try(Transaction tx=db.beginTx()){
Node nod=db.createNode(NodeType.course);
nod.setProperty("name", "comp");
Node nodrim=db.createNode(NodeType.course);
nod.setProperty("name", "info");
}
But nothing is showing on the graph database,the nodes are not added. pleaaasee help.
Upvotes: 0
Views: 1028
Reputation: 803
As @Luanne suggest and a addition to it is to close the transaction if no further use is there. tx.success(); tx.close();
transcation should be closed at the end.
Upvotes: 0
Reputation: 19373
You need to make sure that you commit the transaction-
tx.success()
Upvotes: 3