Bug #31054 Calling absolute in ResultSetImpl doesn't always set MetaData for the new row
Submitted: 17 Sep 2007 11:55 Modified: 31 Mar 2014 15:00
Reporter: Yann Levet Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.3 rc and java 1.6.0_02 OS:Any
Assigned to: Alexander Soklakov CPU Architecture:Any

[17 Sep 2007 11:55] Yann Levet
Description:
To set the new active row in a ResultSet, one can use absolute(int row) to set the cursor on the specified row.

But if the row isn't the first or the last one, the metadata isn't set for the row (instance of ResultSetRow) returned by RowData.getAt(int index)

Users don't use these MetaData, but mysql connector does internally, when a java.sql.Date is required in ResultSetRow.

So a nullPointerException is thrown when 'this.metadata[columnIndex].getMysqlType()' method is called in getDateFast(...) in this particular case :

the row isn't the first or last one AND has been set throught absolute() or relative() or even prev() method. Only next() method set the metadata for the row returned

How to repeat:
1-Create a table with a date field
2-Insert at least three lines with a date in each
3-Obtain a resultSet from the table
4-call next() and getDate(1) : it's OK
5-call absolute(2) and getDate(1) : the exception thrown is 'bad format for date xxxx-xx-xx' despite the fact that the REAL exception is a 'NullPointerException' as specified in the Description

Suggested fix:
Each time a ResultSetRow is returned by the method RowData.getAt(int index)
, set the metadata for the row before returning it.
It will ask an adjustment for next() method.

Next method:

ResultSetRow row = (ResultSetRow) this.rows.get(this.index);
row.setMetadata(this.metadata);
return row

do the same for getAt(int atIndex):

replace "return (ResultSetRow) this.rows.get(atIndex);" by 

ResultSetRow row = (ResultSetRow) this.rows.get(this.index);
row.setMetadata(this.metadata);
return row
[16 Oct 2007 19:38] Sveta Smirnova
test case

Attachment: bug31054.java (text/plain), 838 bytes.

[16 Oct 2007 19:40] Sveta Smirnova
Thank you for the report.

I can not repeat described behaviour with attached test case and current version 5.1.5 of Connector/J. Please upgrade, try with new version on Connector/J and if you can repeat the problem please correct the test.
[17 Nov 2007 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[31 Mar 2014 15:00] Alexander Soklakov
I close this report as "Can't repeat" because there is no feedback for a long time and codebase is too old. Please, feel free to reopen it if the problem still exists in current driver.