Fixed the exception handling of the PDO method by properly using try blocks