Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: [OT] a Collection of beans to store sql data

Len Popp

2007-01-10

Replies:

On 1/10/07, Michael Ni <mikeni123@(protected):
>
> thanks for the quick reply, by the way everyone is telling me to make my
> functions return objects instead of resultset. why is returning resultset
> bad?


Because of this line:
  try {if (rs != null) rs.close();} catch (SQLException e) {}
Your function is closing the result set. If you return a closed ResultSet,
what good is it?

You must close the connection when you're finished with it (so that
connection pooling will work). Before you close the connection, you must
close the ResultSet. Before you close the ResultSet, you must get the data
out of it.
--
Len
©2008 junlu.com - Jax Systems, LLC, U.S.A.