Database Reference
In-Depth Information
DynamicRelationshipType.withName( "KNOWS" );
// To set properties on the relationship, use a
properties map
// instead of null as the last parameter.
inserter.createRelationship(cateNode, russellNode,
knows, null );
} catch (Exception e) {
//Print Exception on Console and shutdown the Inserter
e.printStackTrace();
//Shutdown the Inserter, so that your database is not
corrupted.
inserter.shutdown();
}
//Should be called only once for Batch of statements
inserter.shutdown();
}
public static void main(String[] args) {
try {
new Neo4jBatchInserter().batchInsert();
} catch (Exception e) {
//Print all and any kind of Exception on Console.
e.printStackTrace();
}
}
}
Stop your Neo4j server (if it is running); compile the preceding code and execute it from
the IDE itself. You should now see two nodes inserted by the batch insertion API.
Note
In order to understand the preceding code, follow the comments provided before each line
of the code. This technique is adopted for every code example.
GraphDatabaseService is also supported by the batch insertion API for reusability
of insertion code, which must have been written using the normal Neo4j Java API and not
BatchInserter .
Search WWH ::




Custom Search