PSQLException: this ResultSet is closed

前端 未结 5 917
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-05 08:48

i\'ve occours this strange error for the first time in my life, and i don\'t know what does it means. I\'ve a class that retrieve information from a table on a postgresql da

5条回答
  •  佛祖请我去吃肉
    2021-01-05 09:20

    This is the problem:

    stmt.close();
    conn.close();
    

    You're closing the connection to the database. You can't do that until you've read the data - otherwise how is the ResultSet going to read it? Maybe it will have read some data in to start with, but it's not meant to be a disconnected object.

    In particular, from the docuemntation for ResultSet.close:

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

提交回复
热议问题