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

BIT(1) data type value is different when using ResultSet.getShort() and PreparedStatement/Statement

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.4.5, 1.5.9, 1.6.0, 1.6.4, 1.6.5
    • 2.2.0, 1.7.0
    • Other
    • None

    Description

      A while ago we did JDBC driver upgrade from 1.4.5 to 1.6.4 and noticed an issue when using getShort-method for BIT(1) data type.

      After closer inspection we wrote a test which returns the value using different methods and using PreparedStatement/Statement. Other ResultSet methods (getString, getObject, getByte, getBoolean) return the correct result (0/1), but getShort()-method produces strange results.

      I am not familiar with MariaDB JDBC driver internal logic, but it seems this has to do something with text/binary protocol detection.

      Driver version 1.4.5/1.5.9, using PreparedStatement:
      BIT(1) field value in database 0, getShort returns 0
      BIT(1) field value in database 1, getShort returns 1

      Driver version 1.4.5/1.5.9, using Statement:
      BIT(1) field value in database 0, getShort returns -48
      BIT(1) field value in database 1, getShort returns -47

      Driver version 1.6.0/1.6.4/1.6.5, using PreparedStatement:
      BIT(1) field value in database 0, getShort returns -48
      BIT(1) field value in database 1, getShort returns -47

      Driver version 1.6.0/1.6.4/1.6.5, using Statement:
      BIT(1) field value in database 0, getShort returns -48
      BIT(1) field value in database 1, getShort returns -47

      MariaDB server information:
      version 10.1.26-MariaDB
      version_comment MariaDB Server
      version_compile_machine x86_64
      version_compile_os Linux

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            juharasa Juha Räsänen
            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.