While in the process of upgrading our connector/J to version 5.1 we started seeing the following error:
ComplexByteArrayException: ByteArray objects cannot be converted to strings.
After doing a little homework we found that the root cause was in the way that CONCAT() processed numbers. CONCAT() was returning a binary string due to having both numbers and strings as arguments.
Our fix was to
CAST() all numbers to
CHAR, which results in a normal string being returned. Another option is to call toString() on all of your affected columns when referencing them in the query object.
For example the SQL fix is demonstrated below:
Select Concat('a string', 1)
would return a binary string where as
Select Concat('a string', Cast(1 as char))
would return a "normal" string.