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

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Cannot Reproduce
    • 1.5.8, 1.5.9
    • N/A
    • JDBC 4.2 compatibility
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.