Why should I call close() on a ResultSet and Connection instance?

后端 未结 4 1624
挽巷
挽巷 2020-12-20 12:46

When I don\'t need to use instances of those ResultSet and Connection anymore in my program, why should I call the .close() method on both of them ?

What are the dan

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-20 13:20

    By not closing JDBC connections you increase the likelihood of long waits for idle JDBC connections to be reaped where connection pooling is used. Closing JDBC connections will allow quicker reuse and improve performance.

    Failure to close resultsets, can lead to some databases not freeing up cursor resources.

提交回复
热议问题