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,082,665
  • 372
  • 3,610
  • 3,555
TestAnalyst
  • 543
  • 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,772
  • 5
  • 27
  • 45