commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alik Eliashberg <a...@eliashberg.org>
Subject Statement closing in DbUtils
Date Mon, 01 Nov 2004 18:45:03 GMT
Hello,

I just started using the DbUtils package. I was reading the source code 
and I noticed the following potential problem:

QueryRunner has a 'finally' clause in'query' method. This clause closes 
both ResultSet and the Statement. The problem is that it uses 'close' 
not 'closeQuietly'. So it is possible that if the ResultSet close fails, 
the Statement will remain open forever causing a driver/db resource 
leak. Shouldn't the code be rewritten with another nested 'try/finally':
   try {
      ...
   } finally {
      try {
         DbUtils.close(rs);
      } finally {
          DbUtils.close(stmt);
      }
   }
[Alternatively, 'closeQuetly' can be used, but that would suppress the 
error...]

TIA,

Alik


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message