How does PreparedStatement.executeQuery work?

前端 未结 2 1410
庸人自扰
庸人自扰 2021-01-06 14:32

How PreparedStatement.executeQuery works? Does it fetch results from database and I loop through them? Or it fetches the first result, and on record.next contin

2条回答
  •  迷失自我
    2021-01-06 15:38

    You are doing it correctly. It fetches the entire results from your query, and you loop through them.
    The internal pointer, or cursor, initially starts before the first row, so calling record.next() will move it to the first row.

    http://docs.oracle.com/javase/1.4.2/docs/api/java/sql/ResultSet.html#next%28%29

提交回复
热议问题