JDBC ArrayIndexOutOfBoundsException


#1

I believe I’ve found a bug in the JDBC connector.

I’ve been able to create this useless example which causes an error while using JDBC, but works perfectly fine in the console.

cross_join(
    cross_join(
        build(<name:string>[i=0:*,10000,0],'[albert,bob,chris]',true),
        filter(
            build(<name:string>[j=0:*,10000,0],'[albert,bob,chris,dan]',true),
            j> 0),
        i, j
    ),
    filter(
        build(<name:string>[k=0:*,10000,0],'[albert,bob,chris,dan,edward]',true),
        k > 2),
    i, k)

Changing the second filter to k > 1 makes things work cause it returns a value, but if the cross_join returns nothing then I get the index out of bounds error.


#2

Just as an addendum, I’ve also found that the typical way of walking through a ResultSet does not work with the jdbc connector.

The typical way I’d write code to do so is as follows:

ResultSet rs = ...
while (rs.next()) {
    ...
}

When I do this, I actually find that the result set starts off on the first record, and calling next moves to the second record. As well, rs.next() doesn’t return false after the final record has been reached, so I get an exception after the last record + 1is accessed. This breaks the contract for ResultSet.next() and it looks to me like there’s a fencepost bug here that could very well be related to the index out of bounds error?


#3

Hi, thank you for pointing these out. It looks like in this case the JDBC driver receives a chunk which has no values (because none of the values satisfy the filter) - and it doesn’t know how to handle it gracefully. Will file a bug on this.


#4

Hi cregnier,

I got the same error with you when I using SciDB JDBC. I am wondering if you solved the ArrayIndexOutOfBoundsException?
I tried a lot of ways to solve this error but I failed.