You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Alik Eliashberg <al...@eliashberg.org> on 2004/11/01 19:45:03 UTC

Statement closing in DbUtils

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


Re: Statement closing in DbUtils

Posted by David Graham <gr...@yahoo.com>.
It's been nearly a year since 1.0 was released.  I'll work on getting
DbUtils 1.1 released relatively soon.

David

--- Alik Eliashberg <al...@eliashberg.org> wrote:

> Ah, got it! Do you know when is the next release of DbUtils (that would 
> incorporate this fix)?
> 
> Thank you,
> 
> Alik
> 
> David Graham wrote:
> 
> >This was fixed some time ago as you can see in the latest source here:
>
>http://jakarta.apache.org/commons/dbutils/xref/org/apache/commons/dbutils/QueryRunner.html#235
> >
> >The fix is in the nightly builds.
> >
> >Thanks,
> >David
> >
> >
> >--- Alik Eliashberg <al...@eliashberg.org> wrote:
> >
> >  
> >
> >>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
> >>
> >>
> >>    
> >>
> >
> >
> >
> >		
> >__________________________________ 
> >Do you Yahoo!? 
> >Check out the new Yahoo! Front Page. 
> >www.yahoo.com 
> > 
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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


Re: Statement closing in DbUtils

Posted by Alik Eliashberg <al...@eliashberg.org>.
Ah, got it! Do you know when is the next release of DbUtils (that would 
incorporate this fix)?

Thank you,

Alik

David Graham wrote:

>This was fixed some time ago as you can see in the latest source here:
>http://jakarta.apache.org/commons/dbutils/xref/org/apache/commons/dbutils/QueryRunner.html#235
>
>The fix is in the nightly builds.
>
>Thanks,
>David
>
>
>--- Alik Eliashberg <al...@eliashberg.org> wrote:
>
>  
>
>>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
>>
>>
>>    
>>
>
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Check out the new Yahoo! Front Page. 
>www.yahoo.com 
> 
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>  
>


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


Re: Statement closing in DbUtils

Posted by David Graham <gr...@yahoo.com>.
This was fixed some time ago as you can see in the latest source here:
http://jakarta.apache.org/commons/dbutils/xref/org/apache/commons/dbutils/QueryRunner.html#235

The fix is in the nightly builds.

Thanks,
David


--- Alik Eliashberg <al...@eliashberg.org> wrote:

> 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
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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