GraphDatabaseFactory databaseFactory = new GraphDatabaseFactory();
GraphDatabaseService graphDb = databaseFactory.newEmbeddedDatabase(new File("path/to/neo4j/db"));
Node node1 = graphDb.createNode();
node1.setProperty("name", "Alice");
Node node2 = graphDb.createNode();
node2.setProperty("name", "Bob");
Relationship relationship = node1.createRelationshipTo(node2, RelationshipType.withName("FRIEND"));
relationship.setProperty("since", "2022");
String cypherQuery = "MATCH (n:Person) RETURN n.name";
Result result = graphDb.execute(cypherQuery);
while (result.hasNext()) {
Map<String, Object> row = result.next();
System.out.println(row.get("n.name"));
}