Avoiding skipping a row By next() Method of ResultSet

后端 未结 6 2019
野性不改
野性不改 2021-01-15 00:34

This is a simple code print some rows from a Database. but When I execute this nothing is print on screen. I figured that the problem is rs.next() method is ski

6条回答
  •  無奈伤痛
    2021-01-15 01:11

    Hey it is skipping row because u r doing rs.next() in the if clause and then again in while. So the first iteration which while is doing is actually the second row. Best option will be in if clause u should write if(rs.first())

提交回复
热议问题