neo4j-contrib / neoclipse

Graph Database Tool
218 stars 136 forks source link

Not able to see the relationship which i created in java #69

Open developeranuraggcpl opened 9 years ago

developeranuraggcpl commented 9 years ago

Hi admin,

       I have created a simple relationships code which is here.

package com.graph;

import org.neo4j.graphdb.Direction; import org.neo4j.graphdb.GraphDatabaseService; 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 VisualGraph {

private static final String dbpath="C:/Users/Administrator/Desktop/anurag/demo1";
Node FirstNode;
Node SecondNode;
Node ThirdNode;
Node FourthNode;
Relationship relationship,relationship1;
GraphDatabaseService graphservice;
private static enum Relation implements RelationshipType
{

    FRIENDS,KNOWS,ENEMY;
}

public static void main(String...s) {
VisualGraph visual = new VisualGraph(); visual.createDatabaseConnection(); //visual.removenotes(); visual.shutdown(); }

void createDatabaseConnection() { graphservice = new GraphDatabaseFactory().newEmbeddedDatabase(dbpath); Transaction transaction = graphservice.beginTx(); try {

FirstNode = graphservice.createNode();
FirstNode.setProperty("name", "First Node");
SecondNode = graphservice.createNode();
SecondNode.setProperty("name", "Second Node");
ThirdNode = graphservice.createNode();
ThirdNode.setProperty("name", "Third Node");
FourthNode = graphservice.createNode();
FourthNode.setProperty("name", "Fourth Node");
relationship = FirstNode.createRelationshipTo(SecondNode, Relation.KNOWS);
relationship.setProperty("message", "KNOWS");
relationship1 = SecondNode.createRelationshipTo(ThirdNode, Relation.FRIENDS);
relationship1.setProperty("message1", "FRIENDS");
/*relationship = ThirdNode.createRelationshipTo(FourthNode, Relation.ENEMY);
relationship.setProperty("message2", "ENEMY");*/
System.out.print(FirstNode.getProperty("name")+" "+relationship.getProperty("message")+" "+SecondNode.getProperty("name"));
System.out.println(relationship1.getProperty("message1")+" "+ThirdNode.getProperty("name"));
/*System.out.print(relationship.getProperty("message2")+" "+FourthNode.getProperty("name"));*/
transaction.success();

}
finally
{
    transaction.finish();
}

} void removenotes() { Transaction transaction = graphservice.beginTx(); try { FirstNode.getSingleRelationship( Relation.KNOWS, Direction.OUTGOING ).delete(); System.out.println("RelationShips are deleted...."); FirstNode.delete(); SecondNode.delete(); System.out.println("nodes are deleted......"); transaction.success();

}
finally
{
    transaction.finish();
}

} void shutdown() { graphservice.shutdown(); System.out.println("graph Service is shut downing ......................"); } }

and know i try see the relationship on neoeclipse but i failed.

when i select database location then i will giving the projectworkspace location then it will giving a single node which is coming default not my code.

and when i am giving database location "private static final String dbpath=C:/Users/Administrator/Desktop/anurag/demo1" then giving error.

please tell me admin i am very new in neocplise.

CrystalMethod commented 9 years ago

What's the exact error message you're seeing?