Bugs item #910467, was opened at 2004-03-05 14:23 Message generated for change (Comment added) made by ejort You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376685&aid=910467&group_id=22866
>Category: JBossCX >Group: v3.2 Status: Open >Resolution: Accepted Priority: 5 Submitted By: Xavier Chatelain (xaviou) >Assigned to: Adrian Brock (ejort) Summary: rset.getStatement() and WrappedStatement Initial Comment: OS: Win2K and Linux Fedora1 JDK: 1.4.2 JBoss 3.2.3 DB Informix Hi, In the following simplified code the line stmt = rset.getStatement() doesn't return the PreparedStatement I would like to close (but returns a unknown statement). So I'm getting the warning "Closing a statement you left open, please do your own housekeeping" when executing conx.close(), since I didn't close the right PreparedStatement. Executing pstmt.close() within the finally blocks effectively close the PrepareStatement, but I wouldn't like to do that since all our code has been writen using the ElementosConexao.fecharResultSet() method in order to do so. try { pstmt = conx.prepareStatement(...); pstmt.setInt(1, ...); pstmt.setString(2, ...); rset = pstmt.executeQuery(); } finally { ElementosConexao.fecharResultSet(rset, true); conx.close(); } public static void fecharResultSet(ResultSet rset, boolean fecharStatement){ Statement stmt = null; if (fecharStatement) { stmt = rset.getStatement(); } rset.close(); stmt.close(); } After analysing JBoss source code, it seems this situation occurs because when you create a statement using a connection you obtained from a JBoss data source, the statement returned to you is an instance of WrappedStatement, but when you execute a query, the instance returned to you is the ResultSet of the JDBC driver you are using, so, when you call rset.getStatement (), the statement returned to you is an instance of the Statement of your driver, not the WrappedStatement. Now I have the following question/suggestion: Isnīt it suitable to create a class, for instance, WrappedResultSet, to encapsulate any JBoss specific operation on ResultSets, like obtaining the WrappedStatement instead of the driver's Statement? Thanks a lot, Xavier ---------------------------------------------------------------------- >Comment By: Adrian Brock (ejort) Date: 2004-03-05 15:00 Message: Logged In: YES user_id=9459 Yes, that is the solution. It would also let us track unclosed result sets when using the prepared statement cache. Regards, Adrian ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376685&aid=910467&group_id=22866 ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development