One problem is the code is ignoring exceptions. Add a call to the printStackTrace() method to the catch blocks.