Bug #6197 Connector/J returns wrong type for tinyint
Submitted: 21 Oct 2004 12:52 Modified: 21 Oct 2004 19:46
Reporter: Andy Wu Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.0.15 OS:Linux (Linux/Windows XP)
Assigned to: Mark Matthews CPU Architecture:Any

[21 Oct 2004 12:52] Andy Wu
Description:
Upon upgrading the jdbc driver from 3.0.11 to 3.0.15 I came across the following problem. The column type returned by the driver for a field of type tinyint(1) has changed from java.sql.Types.TINYINT to java.sql.Types.BIT.

I'd try any of the versions between 3.0.11 and 3.0.15 to see when this changed but I can't find any access to download these.

Thanks
Andy Wu

How to repeat:
Create a table containing a field of type tinyint(1) and get the type of that field from the ResultSetMetaData following an executed query.
[21 Oct 2004 12:59] Andy Wu
I got hold of version 3.0.14 and it works i.e. the bug was introduced in 3.0.15.
[21 Oct 2004 13:38] Mark Matthews
The driver does this for JDBC compliance, as the server currently silently converts 'bit' and 'boolean' types to TINYINT(1). The driver can not distinguish between a TINYINT(1) and a bit or boolean type, however it needs to be able to support BIT and BOOLEAN types to be JDBC compliant.

We'll make this configurable in 3.0.16. In the meantime, a work-around would be to alter the column in question to be a TINYINT(>1).
[21 Oct 2004 13:45] Andy Wu
Ok we'll go with that work around. Thanks for the prompt response. Much appreciated.
[21 Oct 2004 19:46] Mark Matthews
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Starting with 3.0.16, you'll be able to use the 'tinyInt1isBit' configuration property, and set it to 'false', and you will have the 3.0.14 behavior.

You can test this using tonight's nightly snapshot build, which hapens in around 10 hours (00:00 GMT) by visiting http://downloads.mysql.com/snapshots.php

(this functionality is actually already in 3.1.x, it just wasn't backported until now).