-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update sample files for testing
- Loading branch information
1 parent
3bc44dc
commit b35ce1a
Showing
5 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
handlers = java.util.logging.ConsoleHandler | ||
java.util.logging.ConsoleHandler.level = ALL | ||
com.google.cloud.grpc.GcpManagedChannel.level=FINEST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
samples/snippets/src/main/java/com/example/spanner/Mux.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.example.spanner; | ||
|
||
import com.google.cloud.spanner.DatabaseClient; | ||
import com.google.cloud.spanner.DatabaseId; | ||
import com.google.cloud.spanner.ResultSet; | ||
import com.google.cloud.spanner.Spanner; | ||
import com.google.cloud.spanner.SpannerOptions; | ||
import com.google.cloud.spanner.Statement; | ||
import java.math.BigDecimal; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
class Mux { | ||
public static void main(String[] args){ | ||
Logger.getLogger("com.google.cloud.grpc.GcpManagedChannel").setLevel(Level.FINEST); | ||
queryWithNumericParameter(); | ||
} | ||
|
||
static void queryWithNumericParameter() { | ||
// TODO(developer): Replace these variables before running the sample. | ||
String projectId = "span-cloud-testing"; | ||
String instanceId = "harsha-test-gcloud"; | ||
String databaseId = "database1"; | ||
|
||
try (Spanner spanner = | ||
SpannerOptions.newBuilder().setProjectId(projectId).enableGrpcGcpExtension().build().getService()) { | ||
DatabaseClient client = | ||
spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId)); | ||
queryWithNumericParameter(client); | ||
} | ||
} | ||
|
||
static void queryWithNumericParameter(DatabaseClient client) { | ||
Statement statement = | ||
Statement.newBuilder( | ||
"SELECT SingerId, FirstName, LastName FROM Singers") | ||
.build(); | ||
try (ResultSet resultSet = client.singleUse().executeQuery(statement)) { | ||
while (resultSet.next()) { | ||
System.out.printf( | ||
"%d %s %s %n", resultSet.getLong("SingerId"), resultSet.getString("FirstName"), resultSet.getString("LastName")); | ||
} | ||
} | ||
} | ||
} |