ensure that statements are closed before creating a new one