@@ -1571,47 +1571,6 @@ static void queryWithQueryOptions(DatabaseClient dbClient) {
15711571 }
15721572 // [END spanner_query_with_query_options]
15731573
1574- // [START spanner_isolation_level_settings]
1575- static void isolationLevelSetting (DatabaseId db ) {
1576- // The isolation level specified at the client-level will be applied to all
1577- // RW transactions.
1578- DefaultReadWriteTransactionOptions transactionOptions =
1579- DefaultReadWriteTransactionOptions .newBuilder ()
1580- .setIsolationLevel (IsolationLevel .SERIALIZABLE )
1581- .build ();
1582- SpannerOptions options =
1583- SpannerOptions .newBuilder ()
1584- .setDefaultTransactionOptions (transactionOptions )
1585- .build ();
1586- Spanner spanner = options .getService ();
1587- DatabaseClient dbClient = spanner .getDatabaseClient (db );
1588- dbClient
1589- // The isolation level specified at the transaction-level takes precedence
1590- // over the isolation level configured at the client-level.
1591- .readWriteTransaction (Options .isolationLevel (IsolationLevel .REPEATABLE_READ ))
1592- .run (transaction -> {
1593- // Read an AlbumTitle.
1594- String select_sql =
1595- "SELECT AlbumTitle from Albums WHERE SingerId = 1 and AlbumId = 1" ;
1596- ResultSet resultSet = transaction .executeQuery (Statement .of (select_sql ));
1597- String title = null ;
1598- while (resultSet .next ()) {
1599- title = resultSet .getString ("AlbumTitle" );
1600- }
1601- System .out .printf ("Current album title: %s\n " , title );
1602-
1603- // Update the title.
1604- String update_sql =
1605- "UPDATE Albums "
1606- + "SET AlbumTitle = 'New Album Title' "
1607- + "WHERE SingerId = 1 and AlbumId = 1" ;
1608- long rowCount = transaction .executeUpdate (Statement .of (update_sql ));
1609- System .out .printf ("%d record updated.\n " , rowCount );
1610- return null ;
1611- });
1612- }
1613- // [END spanner_isolation_level_settings]
1614-
16151574 // [START spanner_create_backup]
16161575 static void createBackup (DatabaseAdminClient dbAdminClient , DatabaseId databaseId ,
16171576 BackupId backupId , Timestamp versionTime ) {
@@ -2116,9 +2075,6 @@ static void run(
21162075 case "querywithqueryoptions" :
21172076 queryWithQueryOptions (dbClient );
21182077 break ;
2119- case "isolationlevelsettings" :
2120- isolationLevelSetting (database );
2121- break ;
21222078 case "createbackup" :
21232079 createBackup (dbAdminClient , database , backup , getVersionTime (dbClient ));
21242080 break ;
@@ -2223,7 +2179,6 @@ static void printUsageAndExit() {
22232179 System .err .println (" SpannerExample querywithtimestampparameter my-instance example-db" );
22242180 System .err .println (" SpannerExample clientwithqueryoptions my-instance example-db" );
22252181 System .err .println (" SpannerExample querywithqueryoptions my-instance example-db" );
2226- System .err .println (" SpannerExample isolationlevelsettings my-instance example-db" );
22272182 System .err .println (" SpannerExample createbackup my-instance example-db" );
22282183 System .err .println (" SpannerExample listbackups my-instance example-db" );
22292184 System .err .println (" SpannerExample listbackupoperations my-instance example-db backup-id" );
0 commit comments