Issue #45 fix

Test the connection with ping and reset connection if ping failed, before further processing query.