6666 * Example code for using the Cloud Spanner PostgreSQL interface.
6767 */
6868public class PgSpannerSample {
69+ // [START spanner_postgresql_insert_data]
6970 static final List <Singer > SINGERS =
7071 Arrays .asList (
7172 new Singer (1 , "Marc" , "Richards" ),
@@ -80,6 +81,7 @@ public class PgSpannerSample {
8081 new Album (2 , 1 , "Green" ),
8182 new Album (2 , 2 , "Forever Hold Your Peace" ),
8283 new Album (2 , 3 , "Terrified" ));
84+ // [END spanner_postgresql_insert_data]
8385
8486 /** Class to contain performance sample data. */
8587 static class Performance {
@@ -201,6 +203,7 @@ static void createPostgreSqlDatabase(DatabaseAdminClient dbAdminClient, Database
201203 // Initiate the request which returns an OperationFuture.
202204 Database db = op .get ();
203205 System .out .println ("Created database [" + db .getId () + "]" );
206+ createTableUsingDdl (dbAdminClient , id );
204207 } catch (ExecutionException e ) {
205208 // If the operation failed during execution, expose the cause.
206209 throw (SpannerException ) e .getCause ();
@@ -652,6 +655,7 @@ static void writeWithTransactionUsingDml(DatabaseClient dbClient) {
652655 // [END spanner_postgresql_dml_getting_started_update]
653656
654657 // [START spanner_postgresql_create_table_using_ddl]
658+ // [START spanner_postgresql_create_database]
655659 static void createTableUsingDdl (DatabaseAdminClient dbAdminClient , DatabaseId id ) {
656660 OperationFuture <Void , UpdateDatabaseDdlMetadata > op =
657661 dbAdminClient .updateDatabaseDdl (
@@ -685,6 +689,7 @@ static void createTableUsingDdl(DatabaseAdminClient dbAdminClient, DatabaseId id
685689 throw SpannerExceptionFactory .propagateInterrupt (e );
686690 }
687691 }
692+ // [END spanner_postgresql_create_database]
688693 // [END spanner_postgresql_create_table_using_ddl]
689694
690695 // [START spanner_postgresql_read_stale_data]
@@ -1319,7 +1324,7 @@ static void run(
13191324 String command ,
13201325 DatabaseId database ) {
13211326 switch (command ) {
1322- case "createpgdatabase " :
1327+ case "createdatabase " :
13231328 createPostgreSqlDatabase (dbAdminClient , database );
13241329 break ;
13251330 case "write" :
@@ -1467,7 +1472,7 @@ static void printUsageAndExit() {
14671472 System .err .println (" PgSpannerExample <command> <instance_id> <database_id>" );
14681473 System .err .println ();
14691474 System .err .println ("Examples:" );
1470- System .err .println (" PgSpannerExample createpgdatabase my-instance example-db" );
1475+ System .err .println (" PgSpannerExample createdatabase my-instance example-db" );
14711476 System .err .println (" PgSpannerExample write my-instance example-db" );
14721477 System .err .println (" PgSpannerExample delete my-instance example-db" );
14731478 System .err .println (" PgSpannerExample query my-instance example-db" );
0 commit comments