The Result Set has no current row

50 Views Asked by At
jdbcTemplate.query (sql, request->{
      do{
         response.put(request.getLong(1),request.getString(2));   
         if(request.getInt(5) != 1){
            responseForMachine.put(request.getString(3),"1A");
         }                                                             
      }while(request.next());
return null;
}, time );

I am getting this error: the result set has no current row.

1

There are 1 best solutions below

0
Joby Wilson Mathews On

You are getting this error because there are no rows available in row set.

Its better to do a check like request.next() before accessing the row data.

Example:

jdbcTemplate.query(sql, request -> {
    while (request.next()) {
        response.put(request.getLong(1), request.getString(2));
        if (request.getInt(5) != 1) {
            responseForMachine.put(request.getString(3), "1A");
        }
    }
    return null;
}, time);