Bug #11388 behavior of Blob.getString() changed from 3.1.6 to 3.1.8
Submitted: 16 Jun 2005 15:39 Modified: 17 Jun 2005 5:46
Reporter: Bryan Hess Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.8 OS:Linux (linux (Red Hat EL3))
Assigned to: CPU Architecture:Any

[16 Jun 2005 15:39] Bryan Hess
It appears that the behavior of Blob.getString() has changed from Connector/J 3.1.6 to 3.1.8. In previous versions, getString returned me the blob interpreted as a String. In the 3.1.8, however, I get the java object toString for a Byte array-- something like [B@444356

I'm running against MySQL 5.0.3 under linux on the server side. The client side, also a linux box, is running under Suns Java 5 runtime. 

Is this an expected change? It could be that I was relying on toString() in an unsopported way, but it caught me off guard. 

How to repeat:
examine the output of  resultSet.getBlob("blob_col_name").toString() on a blob column under 3.1.6 and 3.1.8.

Suggested fix:
Either revert to previous behavior or document the change. I didn't see it in the Changelog.
[16 Jun 2005 16:22] Mark Matthews
There is no .toString() method implemented for our implementation of java.sql.Blob in either 3.1.6, 3.1.7 or 3.1.8.

Are you referring to ResultSet.getString(someBlobColumnIndexOrName) output changing? If so, that's related to this change in 3.1.8:

"Fixed BUG#9236, a continuation of BUG#8868, where functions used in queries 
      that should return non-string types when resolved by temporary tables suddenly 
      become opaque binary strings (work-around for server limitation). Also fixed
      fields with type of CHAR(n) CHARACTER SET BINARY to return correct/matching
      classes for RSMD.getColumnClassName() and ResultSet.getObject()."

You shouldn't really have ever been able to use getString() on a BLOB column, since it has no character encoding, there's no safe way to convert it to a string that doesn't involve corruption or data loss.

Please provide an example of the code that shows _exactly_ what you're referring to so we can provide a better answer.
[16 Jun 2005 16:58] Bryan Hess
Yes, you're right-- resultSet.getString(someBlobColumn) is what I was doing. I will adjust my code accordingly-- thanks!
[17 Jun 2005 5:46] Vasily Kishkin
So....as far as I can understand I can close the bug.