Moved connection object instantiation outside try block.