Jilles van Gurp wrote:
> Hi I'm having difficulties with setting a Text
> field using the setCharacterStream method in a
> preparedstatement:
>
> // if the forum software messes up, the first two
> chars are non ascii multibyte chars
> String v = "þþfoo";
> s = con.prepareStatement("insert into bar (`foo`)
> values (?)");
> StringReader r = new StringReader(v);
> s.setCharacterStream(1,r,v.length());
>
> If I do a select on the table and a
> getCharacterStream I get three characters back
> instead of the 5 I inserted. I lose one character
> at the end for each multibyte char I use in the
> String. As soon as I use setString the problem
> disappears. I've tried using the length in bytes
> instead of chars but that doesn't seem to matter.
>
> I'm using mysql 4.1.12-a-nt and upgraded to the
> latest 3.1.10 jdbc driver. The problem doesn't
> exist with mysql 4.0.x and the same driver.
>
> The reason we use setCharacterStream is that the
> same code is used with oracle & mssql
> (setString doesn't work well with oracle). It's
> pretty old code and it always worked fine with
> mysql 3.x and 4.0. Using the above example I have
> been able to narrow it down. To the
> setCharacterStream call.
Jilles,
Probably related to this bug which will be fixed for 3.1.11:
http://bugs.mysql.com/bug.php?id=11614
-Mark
Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html