Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-444

'Incorrect string value' received when using setBytes on prepared statement

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.5.8, 1.5.9
    • Fix Version/s: N/A
    • Component/s: JDBC 4.2 compatibility
    • 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.

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            csgabor Gabor Csertan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: