| Bug #12167 | getInt() for SMALLINT UNSIGNED column returns incorrect value | ||
|---|---|---|---|
| Submitted: | 25 Jul 2005 23:33 | Modified: | 25 Jul 2005 23:44 |
| Reporter: | Boris Burtin | Email Updates: | |
| Status: | Duplicate | Impact on me: | |
| Category: | Connector / J | Severity: | S1 (Critical) |
| Version: | 3.1.10 | OS: | Any (*) |
| Assigned to: | CPU Architecture: | Any | |
[25 Jul 2005 23:44]
Aleksey Kishkin
duplicate of http://bugs.mysql.com/bug.php?id=11874

Description: When a column is declared as SMALLINT UNSIGNED NOT NULL, the driver incorrectly offsets the value returned from the database by 65536. How to repeat: * Create a table with a column that's declared as SMALLINT UNSIGNED NOT NULL * Insert the value 8 into the column * run "SELECT * FROM my_table" * call ResultSet.getInt(columnName) the value returned is 65544, not 8. I tracked it down to the following code in the ResultSet class: case MysqlDefs.FIELD_TYPE_SHORT: if (!f.isUnsigned()) { return getNativeShort(columnIndex + 1); } return getNativeShort(columnIndex + 1) + 65536; the value returned by getNativeShort() is 8, but the driver still tries to offset it. Suggested fix: Please ensure that the correct value is being returned by ResultSet.getInt() for all integer types.