Skip to content
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

add example for SessionPool #500

Merged
merged 1 commit into from
Dec 29, 2022
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
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,35 @@ Session session = pool.getSession("root", "nebula", false);
session.execute("SHOW HOSTS;");
session.release();
pool.close();
```

## Graph SessionPool example
To use SessionPool, you must config the space to connect for SessionPool. **And please notice that SessionPool
does not support reconnect for broken connection.**
```java
List<HostAddress> addresses = Arrays.asList(new HostAddress("127.0.0.1", 9669));
String spaceName = "test";
String user = "root";
String password = "nebula";
SessionPoolConfig sessionPoolConfig = new SessionPoolConfig(addresses, spaceName, user, password);
SessionPool sessionPool = new SessionPool(sessionPoolConfig);
if (!sessionPool.init()) {
log.error("session pool init failed.");
return;
}
ResultSet resultSet;
try {
resultSet = sessionPool.execute("match (v:player) return v limit 1;");
System.out.println(resultSet.toString());
} catch (IOErrorException | ClientServerIncompatibleException | AuthFailedException | BindSpaceFailedException e) {
e.printStackTrace();
System.exit(1);
} finally {
sessionPool.close();
}





```