protected SQLException closeResources() {
        TraceComponent tc = getTracer();
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); 

        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(this, tc, "closeResources", this); 

        SQLException result = null;

        // InputStream and Reader

        for (Closeable resource : resources)
            try {
                if (resource != null)
                    resource.close(); 
            } catch (IOException ioX) {
                FFDCFilter.processException(
                                            ioX, getClass().getName() + ".closeResources", "316", this);
                if (result == null)
                    result = AdapterUtil.toSQLException(ioX);
            }

        resources.clear();

        // The remaining cleanup options are only available in JDBC 4.0 or higher.
        if (mcf.jdbcDriverSpecVersion >= 40) {
            if (mcf.doArrayCleanup)
                for (Array ra : arrays)
                    try {
                        if (ra != null)
                            ra.free(); 
                    } catch (SQLFeatureNotSupportedException supportX) {
                        // No FFDC code needed.
                        mcf.doArrayCleanup = false;
                        if (isTraceOn && tc.isDebugEnabled())
                            Tr.debug(this, tc, "Array.free is not supported.", supportX); 
                    } catch (SQLException sqlX) {
                        FFDCFilter.processException(
                                                    sqlX, getClass().getName() + ".closeResources", "325", this);
                        if (result == null)
                            result = sqlX;
                    }

            if (mcf.doBlobCleanup)
                for (Blob blob : blobs)
                    try {
                        if (blob != null)
                            blob.free(); 
                    } catch (SQLFeatureNotSupportedException supportX) {
                        // No FFDC code needed.
                        mcf.doBlobCleanup = false;
                        if (isTraceOn && tc.isDebugEnabled())
                            Tr.debug(this, tc, "Blob.free is not supported.", supportX); 
                    } catch (SQLException sqlX) {
                        FFDCFilter.processException(
                                                    sqlX, getClass().getName() + ".closeResources", "348", this);
                        if (result == null)
                            result = sqlX;
                    }

            if (mcf.doClobCleanup)
                for (Clob clob : clobs)
                    try {
                        if (clob != null)
                            clob.free(); 
                    } catch (SQLFeatureNotSupportedException supportX) {
                        // No FFDC code needed.
                        mcf.doClobCleanup = false;
                        if (isTraceOn && tc.isDebugEnabled())
                            Tr.debug(this, tc, "Clob.free is not supported.", supportX); 
                    } catch (SQLException sqlX) {
                        FFDCFilter.processException(
                                                    sqlX, getClass().getName() + ".closeResources", "367", this);
                        if (result == null)
                            result = sqlX;
                    }

            if (mcf.doXMLCleanup)
                for (SQLXML xml : xmls)
                    try {
                        if (xml != null)
                            xml.free(); 
                    } catch (SQLFeatureNotSupportedException supportX) {
                        // No FFDC code needed.
                        mcf.doXMLCleanup = false;
                        if (isTraceOn && tc.isDebugEnabled())
                            Tr.debug(this, tc, "SQLXML.free is not supported.", supportX); 
                    } catch (SQLException sqlX) {
                        FFDCFilter.processException(
                                                    sqlX, getClass().getName() + ".closeResources", "386", this);
                        if (result == null)
                            result = sqlX;
                    }
        }

        arrays.clear();
        blobs.clear();
        clobs.clear();
        xmls.clear();

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(this, tc, "closeResources", result); 
        return result;
    }
protected SQLException closeResources ( ) { TraceComponent tc = getTracer ( ) ; final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( this , tc , "closeResources" , this ) ; SQLException result = null ; for ( Closeable resource : resources ) try { if ( resource != null ) resource . close ( ) ; } catch ( IOException ioX ) { FFDCFilter . processException ( ioX , getClass ( ) . getName ( ) + ".closeResources" , "316" , this ) ; if ( result == null ) result = AdapterUtil . toSQLException ( ioX ) ; } resources . clear ( ) ; if ( mcf . jdbcDriverSpecVersion >= 40 ) { if ( mcf . doArrayCleanup ) for ( Array ra : arrays ) try { if ( ra != null ) ra . free ( ) ; } catch ( SQLFeatureNotSupportedException supportX ) { mcf . doArrayCleanup = false ; if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "Array.free is not supported." , supportX ) ; } catch ( SQLException sqlX ) { FFDCFilter . processException ( sqlX , getClass ( ) . getName ( ) + ".closeResources" , "325" , this ) ; if ( result == null ) result = sqlX ; } if ( mcf . doBlobCleanup ) for ( Blob blob : blobs ) try { if ( blob != null ) blob . free ( ) ; } catch ( SQLFeatureNotSupportedException supportX ) { mcf . doBlobCleanup = false ; if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "Blob.free is not supported." , supportX ) ; } catch ( SQLException sqlX ) { FFDCFilter . processException ( sqlX , getClass ( ) . getName ( ) + ".closeResources" , "348" , this ) ; if ( result == null ) result = sqlX ; } if ( mcf . doClobCleanup ) for ( Clob clob : clobs ) try { if ( clob != null ) clob . free ( ) ; } catch ( SQLFeatureNotSupportedException supportX ) { mcf . doClobCleanup = false ; if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "Clob.free is not supported." , supportX ) ; } catch ( SQLException sqlX ) { FFDCFilter . processException ( sqlX , getClass ( ) . getName ( ) + ".closeResources" , "367" , this ) ; if ( result == null ) result = sqlX ; } if ( mcf . doXMLCleanup ) for ( SQLXML xml : xmls ) try { if ( xml != null ) xml . free ( ) ; } catch ( SQLFeatureNotSupportedException supportX ) { mcf . doXMLCleanup = false ; if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "SQLXML.free is not supported." , supportX ) ; } catch ( SQLException sqlX ) { FFDCFilter . processException ( sqlX , getClass ( ) . getName ( ) + ".closeResources" , "386" , this ) ; if ( result == null ) result = sqlX ; } } arrays . clear ( ) ; blobs . clear ( ) ; clobs . clear ( ) ; xmls . clear ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "closeResources" , result ) ; return result ; }
Clean up after applications in case they don't clean up after themselves.
This method releases the following resources which the application server keeps
track of,

Array, BLOB, CLOB, NCLOB, SQLXML, InputStream, Reader

This method assumes the resource lists are initialized.
Only invoke it if freeResourcesOnClose is TRUE.

@return the first failure to occur, or NULL if all resources are cleaned up,
or if there is nothing to clean up.