public synchronized void closeSpanner ( ) { try { for ( Entry < Spanner , List < CloudSpannerConnection > > entry : connections . entrySet ( ) ) { List < CloudSpannerConnection > list = entry . getValue ( ) ; for ( CloudSpannerConnection con : list ) { if ( ! con . isClosed ( ) ) { con . rollback ( ) ; con . markClosed ( ) ; } } entry . getKey ( ) . close ( ) ; } connections . clear ( ) ; spanners . clear ( ) ; } catch ( SQLException e ) { throw SpannerExceptionFactory . newSpannerException ( e ) ; } }
Closes all connections to Google Cloud Spanner that have been opened by this driver during the lifetime of this application . You should call this method when you want to shutdown your application as this frees up all connections and sessions to Google Cloud Spanner . Failure to do so will keep sessions open server side and can eventually lead to resource exhaustion . Any open JDBC connection to Cloud Spanner opened by this driver will also be closed by this method . This method is also called automatically in a shutdown hook when the JVM is stopped orderly .