[CONJ-535] BIT(1) data type value is different when using ResultSet.getShort() and PreparedStatement/Statement Created: 2017-10-04  Updated: 2017-10-26  Resolved: 2017-10-26

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.4.5, 1.5.9, 1.6.0, 1.6.4, 1.6.5
Fix Version/s: 2.2.0, 1.7.0

Type: Bug Priority: Major
Reporter: Juha Räsänen Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: 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



 Comments   
Comment by Diego Dupin [ 2017-10-26 ]

corrected in 2.2.0 and 1.7.0.

available through snapshot :

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>2.2.0-SNAPSHOT</version>
    </dependency>
</dependencies>

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