Just use the rs.size() method. It will return the number of rowspresent. Else use the following logicint rowCount= 0;while(rs.next()){//do whatever you want with the datarowCount++;}System.out.println("Number of rows = " + rowCount);