It's very similar to a ReaderBut you should consider whether it is better to keep Connections open and cache them, rather than opening and closing them. I don't know about that latter point, which might be better answered on our databases forum. I shall keep this topic here for the time being, however.
Joined: May 06, 2011
Oh, I've always been told to place the finally block after the catch.
Except conn.close() can throw an SQLException of its own. That's why Dean had the initial try-catch inside the finally block.
I always use the form Campbell used*. No need to check for null or anything. The only drawback is that if conn.close() throws an SQLException this will discard any SQLException thrown by the rest of the try block, but that's something I'm willing to live with, as I've never had a close() operation on any connection / stream / Reader / Writer throw an exception.