Added try catch for sql operations