Bug #2662 Inserting data into blobs fails with database, jvm and connection use SJIS
Submitted: 6 Feb 2004 3:55 Modified: 9 Feb 2004 10:09
Reporter: [ name withheld ] Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:C/J 3.0.10 & MySQL 4.0.17 OS:Solaris (Solaris 8 SPARC)
Assigned to: Mark Matthews CPU Architecture:Any

[6 Feb 2004 3:55] [ name withheld ]
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.
[9 Feb 2004 10:09] Mark Matthews
Duplicate of BUG#879.