Bugs item #746298, was opened at 2003-05-30 14:51
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=746298&group_id=22866
Category: JBossServer
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Marc Prud'hommeaux (mprudhom)
Assigned to: Nobody/Anonymous (nobody)
Summary: Lack of WrappedResultSet results in "housekeeping" warnings
Initial Comment:
Using 3.2.1 on OS X, I was seeing a lot of the
following exceptions in our application:
15:41:16,624 WARN [WrappedConnection] Closing a
statement you left open, please do your own housekeeping
We are diligent in closing all our resources, so I
looked into it. The following code (in a JSP) will
issue the Exception:
DataSource source = (DataSource)new InitialContext ()
.lookup ("java:/DefaultDS");
Connection c = source.getConnection ();
out.println ("Connection: " + c.getClass () + "<br>");
Statement s = c.createStatement ();
out.println ("Statement: " + s.getClass () + "<br>");
ResultSet rs = s.executeQuery ("SELECT ID FROM BOOKS");
out.println ("ResultSet: " + rs.getClass () + "<br>");
out.println ("ResultSet.getStatement: "
+ rs.getStatement ().getClass () + "<br>");
out.println ("<ul>");
while (rs.next ())
out.println ("<li>" + rs.getLong (1) + "</li>");
out.println ("</ul>");
rs.close ();
rs.getStatement ().close ();
// the following statement will not result in the
warning
// s.close ();
c.close ();
The problem can be seen in the output of the JSP:
Connection: class
org.jboss.resource.adapter.jdbc.WrappedConnection
Statement: class
org.jboss.resource.adapter.jdbc.WrappedStatement
ResultSet: class org.hsqldb.jdbcResultSet
ResultSet.getStatement: class org.hsqldb.jdbcStatement
The fact that WrappedStatement to return the underlying
Statement's ResultSet means that
ResultSet.getStatement().close() will not be closing
the correct statement: it will be closing the
underlying statement instead of the WrappedStatement.
The recommended solution would be to have a simple
WrappedResultSet that passes though all the method
calls except getStatement(), which will return the
WrappedStatement.
Of course, one possible workaround is to issue the
close() against the Statement that was used to create
the ResultSet, but that is sometimes not possible:
sometimes you only have the ResultSet, and you need to
clean up all the resources using it.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=746298&group_id=22866
-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development