| Bug #19332 | JDBC getString can return | ||
|---|---|---|---|
| Submitted: | 25 Apr 2006 11:21 | Modified: | 1 Sep 2009 11:30 |
| Reporter: | Andy Seaborne | Email Updates: | |
| Status: | Won't fix | Impact on me: | |
| Category: | Connector / J | Severity: | S4 (Feature request) |
| Version: | 5.0.0 | OS: | Any (Java) |
| Assigned to: | CPU Architecture: | Any | |
[25 Apr 2006 11:21]
Andy Seaborne
[25 Apr 2006 16:40]
Mark Matthews
We had more issues when we did what you propose in 3.0 when users didn't understand why certain Strings worked okay, and others got corrupted. If you're storing multiple character sets in MySQL in some sort of LOB, you're much better off with *TEXT with a character encoding of UTF-8, because in JDBC, that's the "correct" mapping of a LOB that has string-y characteristics. That's especially true with MySQL because there is definitely a characeter encoding in place (even if it's UTF-8) that comes "along for the ride" with the TEXT column types. If we were going to follow the JDBC specification to the _letter_ in this case, we should really be throwing an exception, as *BLOB or is not allowed to be converted to a String via ResultSet.getString(). For more details see B-6 in the JDBC-3.0 specification (page 182)
[25 Apr 2006 16:51]
Mark Matthews
One note in that JDBC doesn't allow CLOB to String via getString(), but what we do have with the TEXT types is that it's a LOB _with_ a character encoding. BLOBs don't have a character encoding at all, by definition.
[25 Apr 2006 16:58]
Andy Seaborne
Mark - thanks for the reply. If you had issues when it had the 3.0 behaviour (can't win!) then an exception would be good as well - what I found unexpected was getting back a string but it was "[B@12d7a10" (the .toString() of the byte[]). We are working round this (because we have to support 3.1 drivers and other databases) so this is more user feedback than a potential issue.
