added check for connection status before extracting SQL from buffer