Bug #4281 ResultSetMetaData.getColumnClassName(i) returns wrong Type for Boolean Column
Submitted: 25 Jun 2004 2:38 Modified: 30 Jun 2004 22:58
Reporter: k self Email Updates:
Status: Not a Bug Impact on me:
Category:Connector / J Severity:S2 (Serious)
Version:All OS:Windows (Windows XP/2000)
Assigned to: Mark Matthews CPU Architecture:Any

[25 Jun 2004 2:38] k self
When using the ResultSetMetaData.getColumnClassName() to fetch the class name of a Boolean column, the method returns type Integer. The function getColumnType() returns Types.INTEGER also.

How to repeat:
Generate any Resultset that contains a Boolean column in it and attempt to get the ResultSetMetaData column information for the given Boolean column.

Suggested fix:
[30 Jun 2004 22:58] Mark Matthews
In MySQL, 'boolean' is an alias for 'bit', which is an alias for 'tinyint(1)':

The driver itself can not tell the type of this field as any different from tinyint, because the information is lost.

MySQL-5.0 is scheduled to have a true boolean/bit type.

mysql> create table foo (field1 boolean);
Query OK, 0 rows affected (0.04 sec)

mysql> show columns from foo;
| Field  | Type       | Null | Key | Default | Extra |
| field1 | tinyint(1) | YES  |     | NULL    |       |
1 row in set (0.00 sec)