Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 1.85 KB

README.md

File metadata and controls

46 lines (29 loc) · 1.85 KB

Getting Started with Cloud Spanner and the Google Cloud Client libraries

Open in Cloud Shell

Cloud Spanner is a horizontally-scalable database-as-a-service with transactions and SQL support. These sample Java applications demonstrate how to access the Spanner API using the Google Cloud Client Library for Java.

Quickstart

Install Maven.

Build your project from the root directory (java-spanner):

mvn clean package -DskipTests

Every subsequent command here should be run from a subdirectory (cd samples/snippets).

You can run a given ClassName via:

mvn exec:java -Dexec.mainClass=com.example.spanner.ClassName \
    -DpropertyName=propertyValue \
    -Dexec.args="any arguments to the app"

Running a simple query (using the quickstart sample)

mvn exec:java -Dexec.mainClass=com.example.spanner.QuickstartSample -Dexec.args="my-instance my-database"

Tutorial

Running the tutorial

mvn exec:java -Dexec.mainClass=com.example.spanner.admin.archived.SpannerSample -Dexec.args="<command> my-instance my-database"

Tracing sample

TracingSample.java demonstrates how to export traces generated by client library to StackDriver and to /tracez page.

Running the tracing sample

mvn exec:java -Dexec.mainClass=com.example.spanner.TracingSample -Dexec.args="my-instance my-database"

Test

mvn verify -Dspanner.test.instance=<instance id> -Dspanner.sample.database=<new database id>  -Dspanner.quickstart.database=<existing database id>