|
From: Colin S. <col...@ex...> - 2004-06-18 13:58:39
|
I agree. Now what I usually have done in the past (which is not really an option for Spring in this case), is define a convenience method to close the triad of result, statement, and connection. The method also takes an 'exceptOnError' flag. Basically, I call the method from the finally block, but if an exception handler above the finally block catches a SQLException, I set the flag which will be passed to the convenience method to not throw an exception on error, so the original exception can still bubble up. But for this case, I think logging is probably best... We could also add a new variant of the closeConnectionIfNecessary method, which takes a boolean as to whether an exception should be thrown, or just logged. That way, code which knows that it is calling the method from an error free area can still call with the flag set appropriately to get the existing behaviour. Colin Thomas Risberg wrote: > I would agree that logging is more appropriate in the finally clause > in this case. > > Thomas > > jürgen höller [werk3AT] wrote: > >> Thomas, Rod, everybody, >> >> There is an issue regarding >> DataSourceUtils.closeConnectionIfNecessary in our JIRA: >> >> http://opensource.atlassian.com/projects/spring/browse/SPR-172 >> >> This is indeed undesirable. Of course, Connection.close hardly ever >> throws an exception, so it's not a big problem. We could still simply >> log the exception as an error and proceed, like we do in >> JdbcUtils.closeStatement/closeResultSet. >> >> What do you think? >> >> Juergen >> |