Joe Weinstein said:
It's a function of DBMS-side cursors which are associated with open statements
and open result sets. It is common, correct JDBC hygiene to close such objects
ASAP, and for Oracle it is more important than for some DBMSes. Oracle permits
a fixed (configurable) number of cursors that a client can have open at one
time. An application that caches or ignores too many open statements or result
sets can get errord if it exceeds the DBMS limit. It's not a JDBC issue as such.
Apparently you haven't been reading the thread. Oracle's JDBC driver
should not be holding a ResultSet open across a Connection.close() --
nor a commit() unless a non-default holdability was set using JDBC3's
new overloads of createStatement and prepareStatement. Nor should it
survive a Statement.execute() or getMoreResults() (the version with no
parameters). If the Oracle driver is producing ResultSet instances that
sutvive these things, then it is in violation of the spec, including
(but not limited to) sections 10.1, 14.1.3, 14.2.5, Oracle's driver is
broken, and it's broken in a particularly gruesome way.
The spec (somewhat confusingly, and for no good reason that I can see)
allows for greater leeway for Statement.close() -- requiring the driver
to immediately invalidate and "close" the ResultSet, but permitting it
to hold off on releasing resources until the next garbage collection.
That's not a particularly useful allowance, and I imagine that there are
probably no drivers that take advantage of it but still comply with the
spec. It appears that the author of the specification does not actually
understand garbage collection in Java. That theory is confirmed when
section 14.2.5 specifies that calling ResultSet.close() makes the
ResultSet object immediately available for garbage collection -- a
ludicrous requirement that invalidates the entirety of the Java security
model, and requires a heavily modified virtual machine to actually
implement correctly (luckily, no one actually takes this requirement of
the spec seriously).
Clearly that is in fact a JDBC issue, since it's about whether Oracle's
driver complies certain requirements of the JDBC specification or not.
If it is confirmed that this is a problem with Oracle's JDBC driver,
then apparently it will become necessary to make calls to
ResultSet.close() in the middle of a tight loop of PreparedStatement's
execute() calls. That would then be classified as a work-around for a
serious bug, *not* as good general practice for JDBC.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation