I am new in neo4j and I am trying to learn,
I have the following java code for creating the node in neo4j and then I read the property name of created node in java,my code is as follow:
String DB_PATH = "C:/hamed";
public static void main( String[] args )
{
JavaQuery javaQuery = new JavaQuery();
javaQuery.run();
}
void run()
{
// START SNIPPET: addData
GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );
db.beginTx();
try ( Transaction tx = db.beginTx(); )
{
Node myNode = db.createNode();
myNode.addLabel( DynamicLabel.label( "11" ) );
myNode.setProperty( "name", "qq" );
tx.success();
}
// END SNIPPET: addData
// START SNIPPET: execute
ExecutionEngine engine = new ExecutionEngine( db );
ExecutionResult result;
try ( Transaction ignored = db.beginTx() )
{
result = engine.execute( "match (n) return n, n.name" );
// END SNIPPET: execute
// START SNIPPET: items
Iterator<Node> n_column = result.columnAs( "n" );
for ( Node node : IteratorUtil.asIterable( n_column ) )
{
// note: we're grabbing the name property from the node,
// not from the n.name in this case.
nodeResult = node + ": " + node.getProperty( "name" );
System.out.println("ss : "+nodeResult);
}
// END SNIPPET: items
db.shutdown();
}
and the system.out... prints ss : Node1: qq which is good,
Now when I run the neo4j as follow:
then I go to this link:
http://localhost:7474/webadmin/
and then when I write query to check nodes nothing returns:
But I expect to see one node with the name property of qq
can anyone help me? what am I doing wrong?
Update:
I undersood that code only removes all nodes from db. for example I created a node and check it with neo4j console : match (n) return n and the node returned but after running the code nothing returned which is very strange!!!!!!!!!!