0

I have two cursors which are used to display details in UI.

headerCur = (ResultSet) cstmt.getObject(4);
serialCur = (ResultSet) cstmt.getObject(5); 

When the user enters a wrong value, it goes to serialCur.next().

while (serialCur.next()) {
    // ...
} 

However, it throws a NullPointerException.

I have logged and found that the serialCur is not null, but the next() call throws null pointer exception anyway.

How is this caused and how can I solve it?

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
TestAnalyst
  • 413
  • 1
  • 4
  • 9

1 Answers1

-2

Use

 while (serialCur.isBeforeFirst() ) {
// ...
} 

OR

if(serialCur.isBeforeFirst()) {
while (serialCur.next() ) {
// ...
} 
}

to check if result set has a value

Nipun Alahakoon
  • 2,582
  • 3
  • 26
  • 43