Moved getRConnection() calls into try blocks and always closing in
finally blocks.

Change-Id: Id307ce23358da478f7e9abdd1df49a071ea14497