一些例子老是报错,也不知道是为什么原因。。比如说这个:
GraphDatabaseService graphDb = new EmbeddedGraphDatabase( “helloworld” );
Transaction tx = graphDb.beginTx();
try {
Node firstNode = graphDb.createNode();
Node secondNode = graphDb.createNode();
firstNode.setProperty( "message", "Hello, " );
secondNode.setProperty( "message", "world!" );
Relationship relationship = firstNode.createRelationshipTo( secondNode,
DynamicRelationshipType.of("KNOWS") );
relationship.setProperty( "message", "brave Neo4j " );
tx.success();
} finally {
tx.finish();
}
请问需要怎么更改才能正常运行呢?或者给一个其他的简单代码例子也可以,不胜感激!
官方有例子: Driver driver = GraphDatabase.driver( “bolt://localhost:7687”, AuthTokens.basic( “neo4j”, “neo4j” ) ); Session session = driver.session();
session.run( “CREATE (wd:Person {name: {name}, title: {title}})”, parameters( “name”, “node”, “title”, “Test” ) );
StatementResult result = session.run( "MATCH (node:Person) WHERE node.name = {name} " + “RETURN node.name AS name, node.title AS title”, parameters( “name”, “node” ) ); while ( result.hasNext() ) { Record record = result.next(); System.out.println( record.get( “title” ).asString() + " " + record.get( “name” ).asString() ); } session.close(); driver.close();