Database Reference
In-Depth Information
final PreparedStatement statement = conn.prepareStatement(query);
for (Map.Entry<String, Object> entry : params.entrySet()) {
int index = Integer.parseInt(entry.getKey());
statement.setObject(index, entry.getValue());
}
final ResultSet result = statement.executeQuery();
}
Querying with a Label
To get nodes that use a specific label, use a MATCH clause, similar to previous examples, and, in this instance, set a
LIMIT of 50 nodes to be returned (Listing 12-13).
Listing 12-13. Querying with a Label
public Iterable GetNodesByLabel() {
// Make sure Neo4j Driver is registered
Class.forName("org.neo4j.jdbc.Driver");
// Connect
Connection conn = DriverManager.getConnection("jdbc:neo4j://localhost:7474/");
String query= " MATCH (users:User) " +
" RETURN users " +
" LIMIT 50 ";
final PreparedStatement statement = conn.prepareStatement(query);
final ResultSet result = statement.executeQuery();
}
Developing a Java and Neo4j Application
This section covers the basics of configuring a development environment, preliminary to building out your first Java
and Neo4j application. Again, if you have not worked through the installation steps in Chapter 2, take a few minutes
to review the steps and configure your development environment before continuing.
Preparing the Graph
In order to spend more time highlighting code examples for each of the more common graph models, you will use
a preloaded instance of Neo4j including necessary plugins, such as the spatial plugin.
 
Search WWH ::




Custom Search