Bug #26592 PreparedStatement is not closed in BlobFromLocator.getBytes
Submitted: 23 Feb 2007 13:35 Modified: 13 Apr 2007 8:33
Reporter: Constantine Bozhkov Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.0.4 OS:Any (All)
Assigned to: CPU Architecture:Any

[23 Feb 2007 13:35] Constantine Bozhkov
Description:
Method BlobFromLocator.getBytes(long, int) creates a new PreparedStatement, which is not closed afterwards. The code in the 'finally' block attempts to close a result set, which is never initialized in this method.

In a web application using a pool to connect to the DB these PreparedStatements accumulate and finally cause OutOfMemoryError.

How to repeat:
No need to repeat, the bug is obvious when looking at code.

Suggested fix:
Replace blobRs with pStmt in the finally block and remove blobRs variable.
[1 Mar 2007 22:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/20950
[13 Apr 2007 8:33] MC Brown
A note has been added to the 5.0.6 changelog.