[CONJ-444] 'Incorrect string value' received when using setBytes on prepared statement Created: 2017-03-14  Updated: 2021-02-08  Resolved: 2021-02-08

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: 1.5.8, 1.5.9
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Gabor Csertan Assignee: Diego Dupin
Resolution: Cannot Reproduce Votes: 0
Labels: None
Environment:

Manjaro Linux
MariaDB 10.1.20



 Description   

We recently replaced the MySQL JDBC connector with MariaDB connector in our project.
We have a table with latin1 encoding but sometimes we have to insert values that contain japanese characters, for this we used PreparedStatement.setBytes which worked fine until we did the switch.

A workaround for this is to use setBinaryStream instead of setBytes.

The cause might lie in how ParameterWriter writes a byte[] vs an InputStream: when writing an array it prepends the data with _binary' while it only writes a single quote for streams.

By looking at the network traffic I found that the MySQL connector sends the data converted to hexadecimal and prepended with an x when using setBytes and sends the raw bytes prepended with _binary for setBinaryStream, while the MariaDB connector does the same for setBytes and sends just the raw bytes for setBinaryStream.



 Comments   
Comment by Diego Dupin [ 2021-02-08 ]

Close because not reproduced, and no activity since 5 years

Generated at Thu Feb 08 03:15:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.