java jdbc accessing multiple resultsets

后端 未结 3 1786
既然无缘
既然无缘 2020-12-18 14:54

I have the following structure:

List -->List_Participant -->Participant

so a list may contain several participants.I try to read this in java:



        
3条回答
  •  别那么骄傲
    2020-12-18 15:47

    Here is the reason why you can't have two ResultSet opened from the same Statement

    ResultSet javadoc :

    A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.

    So basicly, a Statement can only give you one ResultSet at a time, so you loose the first result when you execute the second query.

    Solution :

    • Using one instance of Statement per ResultSet needed.
    • merging the queries to only have one

提交回复
热议问题