Derby is throwing exception with code 42802. It seems, this particular piece of code is source of trouble, but I cannot see why.
if(!resultSet.next())