Description:
We're trying to store binary data into BLOBs on a database which has SJIS as the standard character set.
The JVM is also using SJIS (Shift_JIS) as default charset and the connection is defined to use SJIS
characterset. After creating a prepared statement and having put binary data into the statement,
excecuting the statement results in
java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your
SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to
use near <binary junk here>"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2051)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1680)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1527)
The same code works perfectly with latin1 installations. Googling revealed some people think this is
caused by the driver and server interpreting quotes differently in the character stream.
How to repeat:
Create a table with a blob, set the default character encoding in the db to sjis, start your jvm with
-Dfile.encoding=Shift_JIS and try to store binary data. We're trying to store zipped data so using
java.util.zip to compress text for storage might be a good set of data.
Suggested fix:
Don't have a suggestion, sorry.