Function Connection.cancel

Try to cancel query

void cancel();

If the cancellation is effective, the current command will terminate early and return an error result or exception. If the cancellation will fails (say, because the server was already done processing the command) there will be no visible result at all.