Can we execute some queries while traversing resultset in java

后端 未结 4 692
春和景丽
春和景丽 2021-01-05 16:30

I am trying to implement a task in java using JDBC like Stored Procedure in SQL. In SQL, when we write cursor, first we execute select query and then fetching the records we

4条回答
  •  一生所求
    2021-01-05 17:12

    Each Statement can only have one open ResultSet at a time. From the documentation:

    By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.

    The calls to executeQuery inside your loop will implicitly close the outer ResultSet, so that's why you only see one row.

提交回复
热议问题