I was reading this thread and couldn't help but notice that in the code it doesn't appear you are actually closing the connection. Notice that the code is only calling connection.close() if the connection == null, which will not work and indeed could land you an exception if it ever did get called.
[Message sent by forum member 'dominic_mcginnis' (dominic_mcginnis_at_yahoo.com)]
http://forums.java.net/jive/thread.jspa?messageID=363446