Skip to content

Commit a93e3e3

Browse files
vkediagarrettjonesgoogle
authored andcommitted
Fix the code snippet in README (#2455)
1 parent 029b8da commit a93e3e3

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

google-cloud-spanner/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,15 @@ try {
8585
DatabaseClient dbClient = spanner.getDatabaseClient(
8686
DatabaseId.of(options.getProjectId(), instance, database));
8787
// Queries the database
88-
ResultSet resultSet = dbClient.singleUse().executeQuery(Statement.of("SELECT 1"));
89-
// Prints the results
90-
while (resultSet.next()) {
91-
System.out.printf("%d\n", resultSet.getLong(0));
88+
try (ResultSet resultSet = dbClient.singleUse().executeQuery(Statement.of("SELECT 1"))) {
89+
// Prints the results
90+
while (resultSet.next()) {
91+
System.out.printf("%d\n", resultSet.getLong(0));
92+
}
9293
}
9394
} finally {
9495
// Closes the client which will free up the resources used
95-
spanner.closeAsync().get();
96+
spanner.close();
9697
}
9798
```
9899

0 commit comments

Comments
 (0)