Skip to content

Updated the SimpleExample #658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions driver/src/main/javadoc/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<h3>Example</h3>

<pre><code>import org.neo4j.driver.v1.*;
<pre><code>import org.neo4j.driver.*;

import static org.neo4j.driver.Values.parameters;

Expand All @@ -28,21 +28,21 @@ <h3>Example</h3>
// Sessions are lightweight and disposable connection wrappers.
try (Session session = driver.session())
{
// Wrapping Cypher in an unmanaged transaction provides atomicity
// Wrapping a Cypher Query in a Managed Transaction provides atomicity
// and makes handling errors much easier.
try (Transaction tx = session.beginTransaction())
{
tx.run("MERGE (a:Person {name: $x})", parameters("x", name));
tx.success(); // Mark this write as successful.
}
// Use `session.writeTransaction` for writes and `session.readTransaction` for reading data.
// These methods are also able to handle connection problems and transient errors using an automatic retry mechanism.
session.writeTransaction(tx -> tx.run("MERGE (a:Person {name: $x})", parameters("x", name)));
}
}

private void printPeople(String initial)
{
try (Session session = driver.session())
{
// Auto-commit transactions are a quick and easy way to wrap a read.
// A Managed Transaction transactions are a quick and easy way to wrap a Cypher Query.
// The `session.run` method will run the specified Query.
// This simpler method does not use any automatic retry mechanism.
Result result = session.run(
"MATCH (a:Person) WHERE a.name STARTS WITH $x RETURN a.name AS name",
parameters("x", initial));
Expand Down