Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import org.neo4j.graphdb.GraphDatabaseService;
- import org.neo4j.graphdb.Label;
- import org.neo4j.graphdb.Node;
- import org.neo4j.graphdb.Relationship;
- import org.neo4j.graphdb.RelationshipType;
- import org.neo4j.graphdb.Transaction;
- import org.neo4j.graphdb.factory.GraphDatabaseFactory;
- public class Operation {
- //private static final File file =new File();
- public static void main(String[] args) {
- GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
- GraphDatabaseService db= dbFactory.newEmbeddedDatabaseBuilder("C:\Users\pritom.mazumdar\Downloads\neo4j-community-3.5.0-alpha07\data\databases\graph.db").newGraphDatabase();
- //Transaction tx = db.beginTx();
- try (Transaction tx = db.beginTx()) {
- Node javaNode = db.createNode();
- javaNode.setProperty("TutorialID", "JAVA001");
- javaNode.setProperty("Title", "Learn Java");
- javaNode.setProperty("NoOfChapters", "25");
- javaNode.setProperty("Status", "Completed");
- Node scalaNode = db.createNode();
- scalaNode.setProperty("TutorialID", "SCALA001");
- scalaNode.setProperty("Title", "Learn Scala");
- scalaNode.setProperty("NoOfChapters", "20");
- scalaNode.setProperty("Status", "Completed");
- Relationship relationship = javaNode.createRelationshipTo(scalaNode, (RelationshipType) Label.label("JVM_LANG"));
- relationship.setProperty("Id","1234");
- relationship.setProperty("OOPS","YES");
- relationship.setProperty("FP","YES");
- tx.success();
- }
- System.out.println("Done successfully");
- }
- }
Add Comment
Please, Sign In to add comment