Suri
Suri

Reputation: 17

What are disadvantages to return type as resultset in method

What are side effects when iam return a Resulset(java.sql.ResultSet) in the method using java.

Upvotes: 0

Views: 559

Answers (1)

Thilo
Thilo

Reputation: 262534

It leaks the ResultSet out of the method. This means that it is up to the caller to clean up the Connection. Only do this if the ResultSet contains too much data to simply copy it into memory (and then close it within the method), and if the caller can be expected to manage database connections (for example, when the Connection was passed into the method as a parameter as well).

Upvotes: 2

Related Questions