Menu

#22 Bad Row Count / NegativeArrayIndexException

closed
None
5
2012-10-04
2006-07-24
Anonymous
No

I received an Exception:

java.lang.NegativeArraySizeException
com.healthmarketscience.jackcess.Table.getNextRow(Table.java:200)
com.healthmarketscience.jackcess.Table.getNextRow(Table.java:162)
...in my code here...

To reproduce this:
in a new Access DB, create a table with the following
definition:
Column 1: auto-increment, PK
Column 2: Currency

I then populated this table with 2 rows: the first with
the value $5.23, and the second with the value -$100.00.

Then, while iterating over the rows of this table, I
received the above exception. It seems that
"positionAtNextRow" (line 185 of Table.java) did not
return null, and it thinks there are still more rows
(after having read the 2nd row). However, when
calculating the column count again (line 199) it reads
that there are "-1" columns (this causes the
aforementioned Exception).

While I don't know why this happens, it appears that
just adding the additional check:

if(varColumnCount<0) return null; //how did we get here?

seems to fix the problem.

Thanks, james

Discussion


Log in to post a comment.

MongoDB Logo MongoDB