added finally blocks to the mysql blocks