protected void close ( boolean closeWrapperOnly ) throws SQLException { TraceComponent tc = getTracer ( ) ; final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( this , tc , "close" ) ; // Make sure we only get closed once. if ( state == State . CLOSED ) // already closed, just return { if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "close" , "Already closed" ) ; return ; } state = State . CLOSED ; if ( isTraceOn && tc . isEventEnabled ( ) ) Tr . event ( this , tc , "state --> " + state . name ( ) ) ; // Close all children. Then close the current wrapper, saving the first exception // encountered. Others are logged. closeChildWrappers ( ) ; SQLException sqlX = freeResourcesOnClose ? closeResources ( ) : null ; SQLException sqlX2 = closeWrapper ( closeWrapperOnly ) ; sqlX = sqlX == null ? sqlX2 : sqlX ; // When JDBC event listeners are enabled, the connection error notification is sent // prior to raising the error, which means close is invoked prior to mapException. // The reference to the parent wrapper must be kept so that exception mapping can // still be performed. childWrappers = null ; ifcToDynamicWrapper . clear ( ) ; dynamicWrapperToImpl . clear ( ) ; if ( sqlX != null ) { if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "close" , sqlX ) ; throw sqlX ; } if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "close" ) ; }
Default close method for all JDBC wrappers accessible to users . This method closes all child wrappers and invokes the closeWrapper method implemented by the wrapper subclass . If the wrapper is already closed a message stating the wrapper has already been closed is logged to the trace .