The logic in the code snippet does not evaluate the status of the connection, it evaluates if rs is null (calling close on a stream/resultset/etc...does not nullify the object reference).