Why does JdbcRowSetImpl.close() close the database connection?

  • Thread starter Paul van Rossem
  • Start date
P

Paul van Rossem

(Posted this few weeks ago in c.l.j.databases, but got no reaction...)

In my opinion it is a design flaw that JdbcRowSetImpl.close() not only
closes the ResultSet, but also closes the database connection. The
ResultSet.close() interface specification, i.e. the contract that
JdbcRowSetImpl.close() should implement, does not mention this. I
consider this also an unwanted side-effect, since the close() is a
method of the RowSet, not of the Connection. And for instance
CachedRowSet does as expected: not closing the connection (and usually
can't). Any opinions on this? Or is this simply a bug?

I would like to be able to construct several JdbcRowSets on an existing
Connection. The JdbcRowSet(Connection) constructor suggests this is
possible. But this becomes a hassle if closing one of the JdbcRowSets
closes the Connection for all of them. I assume that re-opening the
connection for each JdbcRowSet (using the JdbcRowSet.execute() method)
causes a lot of unneeded overhead in logging in and out on the database
server for each data fetch, which I am doing a lot. Am I right?

I am considering to file a feature request (or even bug report?) with
SUN to have JdbcRowSetImpl.close() only discard the dataset, and add a
separate JdbcRowSetImpl.closeConnection() as a utility method to close
the database connection. Any opinions on this will be greatly appreciated...

Regards, Paul.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top