We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 029b8da commit a93e3e3Copy full SHA for a93e3e3
1 file changed
google-cloud-spanner/README.md
@@ -85,14 +85,15 @@ try {
85
DatabaseClient dbClient = spanner.getDatabaseClient(
86
DatabaseId.of(options.getProjectId(), instance, database));
87
// 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));
+ try (ResultSet resultSet = dbClient.singleUse().executeQuery(Statement.of("SELECT 1"))) {
+ // Prints the results
+ while (resultSet.next()) {
+ System.out.printf("%d\n", resultSet.getLong(0));
92
+ }
93
}
94
} finally {
95
// Closes the client which will free up the resources used
- spanner.closeAsync().get();
96
+ spanner.close();
97
98
```
99
0 commit comments