rwaldhoff 2002/10/31 13:14:32 Modified: dbcp/src/java/org/apache/commons/dbcp DelegatingCallableStatement.java DelegatingPreparedStatement.java DelegatingResultSet.java DelegatingStatement.java Log: make sure Delegating*Statement.getResultSet and related methods don't wrap a null value returned by the underlying class (this addresses http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12733, with Tim Funk's patch and some other small changes) Revision Changes Path 1.6 +10 -9 jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingCallableStatement.java Index: DelegatingCallableStatement.java =================================================================== RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingCallableStatement.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DelegatingCallableStatement.java 30 Oct 2002 00:46:02 -0000 1.5 +++ DelegatingCallableStatement.java 31 Oct 2002 21:14:32 -0000 1.6 @@ -1,5 +1,5 @@ /* - * $Header$ + * $Id$ * $Revision$ * $Date$ * @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,6 +97,7 @@ * * @author Glenn L. Nielsen * @author James House (<a href="mailto:james@;interobjective.com">[EMAIL PROTECTED]</a>) + * @version $Revision$ $Date$ */ public class DelegatingCallableStatement extends AbandonedTrace implements CallableStatement { @@ -131,11 +132,11 @@ */ public void close() throws SQLException { if(_conn != null) { - _conn.removeTrace(this); + _conn.removeTrace(this); _conn = null; } - // The JDBC spec requires that a statment close any open + // The JDBC spec requires that a statement close any open // ResultSet's when it is closed. List resultSets = getTrace(); if( resultSets != null) { @@ -155,15 +156,15 @@ } public ResultSet executeQuery() throws SQLException { - return new DelegatingResultSet(this, _stmt.executeQuery()); + return DelegatingResultSet.wrapResultSet(this,_stmt.executeQuery()); } public ResultSet getResultSet() throws SQLException { - return new DelegatingResultSet(this, _stmt.getResultSet()); + return DelegatingResultSet.wrapResultSet(this,_stmt.getResultSet()); } public ResultSet executeQuery(String sql) throws SQLException { - return new DelegatingResultSet(this, _stmt.executeQuery(sql)); + return DelegatingResultSet.wrapResultSet(this,_stmt.executeQuery(sql)); } public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { _stmt.registerOutParameter( parameterIndex, sqlType); } 1.6 +8 -10 jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingPreparedStatement.java Index: DelegatingPreparedStatement.java =================================================================== RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingPreparedStatement.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DelegatingPreparedStatement.java 29 Jun 2002 17:36:37 -0000 1.5 +++ DelegatingPreparedStatement.java 31 Oct 2002 21:14:32 -0000 1.6 @@ -1,5 +1,5 @@ /* - * $Header$ + * $Id$ * $Revision$ * $Date$ * @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,6 +85,7 @@ * @author Rodney Waldhoff * @author Glenn L. Nielsen * @author James House (<a href="mailto:james@;interobjective.com">[EMAIL PROTECTED]</a>) + * @version $Revision$ $Date$ */ public class DelegatingPreparedStatement extends AbandonedTrace implements PreparedStatement { @@ -163,20 +164,17 @@ public ResultSet executeQuery(String sql) throws SQLException { checkOpen(); - - return new DelegatingResultSet(this, _stmt.executeQuery(sql)); + return DelegatingResultSet.wrapResultSet(this,_stmt.executeQuery(sql)); } public ResultSet getResultSet() throws SQLException { checkOpen(); - - return new DelegatingResultSet(this, _stmt.getResultSet()); + return DelegatingResultSet.wrapResultSet(this,_stmt.getResultSet()); } public ResultSet executeQuery() throws SQLException { checkOpen(); - - return new DelegatingResultSet(this, _stmt.executeQuery()); + return DelegatingResultSet.wrapResultSet(this,_stmt.executeQuery()); } public int executeUpdate(String sql) throws SQLException { checkOpen(); return _stmt.executeUpdate(sql);} 1.4 +12 -3 jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingResultSet.java Index: DelegatingResultSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingResultSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DelegatingResultSet.java 5 Aug 2002 06:25:59 -0000 1.3 +++ DelegatingResultSet.java 31 Oct 2002 21:14:32 -0000 1.4 @@ -114,6 +114,15 @@ this._stmt = stmt; this._res = res; } + + public static ResultSet wrapResultSet(Statement stmt, ResultSet rset) { + if(null == rset) { + return null; + } else { + return new DelegatingResultSet(stmt,rset); + } + } + public Statement getStatement() throws SQLException { return _stmt; 1.6 +10 -9 jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingStatement.java Index: DelegatingStatement.java =================================================================== RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DelegatingStatement.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DelegatingStatement.java 29 Jun 2002 17:36:37 -0000 1.5 +++ DelegatingStatement.java 31 Oct 2002 21:14:32 -0000 1.6 @@ -1,5 +1,5 @@ /* - * $Header$ + * $Id$ * $Revision$ * $Date$ * @@ -7,7 +7,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,6 +82,7 @@ * @author Rodney Waldhoff (<a href="mailto:rwaldhof@;us.britannica.com">[EMAIL PROTECTED]</a>) * @author Glenn L. Nielsen * @author James House (<a href="mailto:james@;interobjective.com">[EMAIL PROTECTED]</a>) + * @version $Revision$ $Date$ */ public class DelegatingStatement extends AbandonedTrace implements Statement { /** My delegate. */ @@ -106,6 +107,7 @@ /** * Returns my underlying {@link Statement}. * @return my underlying {@link Statement}. + * @see #getInnermostDelegate */ public Statement getDelegate() { return _stmt; @@ -125,6 +127,7 @@ * This method is useful when you may have nested * <tt>DelegatingStatement</tt>s, and you want to make * sure to obtain a "genuine" {@link Statement}. + * @see #getDelegate */ public Statement getInnermostDelegate() { Statement s = _stmt; @@ -158,14 +161,12 @@ public ResultSet executeQuery(String sql) throws SQLException { checkOpen(); - - return new DelegatingResultSet(this, _stmt.executeQuery(sql)); + return DelegatingResultSet.wrapResultSet(this,_stmt.executeQuery(sql)); } public ResultSet getResultSet() throws SQLException { checkOpen(); - - return new DelegatingResultSet(this, _stmt.getResultSet()); + return DelegatingResultSet.wrapResultSet(this,_stmt.getResultSet()); } public int executeUpdate(String sql) throws SQLException { checkOpen(); return _stmt.executeUpdate(sql);} @@ -228,7 +229,7 @@ ((DelegatingPreparedStatement)_stmt).passivate(); } } - + protected boolean _closed = false; // ------------------- JDBC 3.0 -----------------------------------------
-- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>