Hi Steve

Great idea. Have implemented this in CVS HEAD now.

I also applied Hristo's patches (see the thread on commons-user) so that
statement and result sets are closed during normal execution and their
exceptions will be thrown.
So typically the catching of close() exceptions only occurs now when an
exception has been called already; so catching the closure exceptions helps
keep the original exceptions bubbling up.

James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: "Steve Downey" <[EMAIL PROTECTED]>
To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
Sent: Thursday, September 26, 2002 9:41 PM
Subject: Re: cvs commit:
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql
QueryTag.java


re:
>   +                catch (SQLException e) {
>   +                } // Not much we can do

how about
                catch (SQLException e) {
                    log.error(e);
//or whatever the right syntax is with commons logging
                } // Not much we can do

There should probably be an log.error() in there, as something really
hideous,
and nearly impossible, just happened. Like the connection between the app
and
the db was dropped. Or the db has crashed. Proceeding on is probably an OK
idea, athough things might grind to a halt soon after.

On Thursday 26 September 2002 02:35 pm, [EMAIL PROTECTED] wrote:
> jstrachan    2002/09/26 11:35:23
>
>   Modified:    jelly/src/java/org/apache/commons/jelly/tags/sql
>                         QueryTag.java
>   Log:
>   Patch for bug scarab#12888
>
>   Revision  Changes    Path
>   1.10      +18 -2
>
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/Qu
>eryTag.java
>
>   Index: QueryTag.java
>   ===================================================================
>   RCS file:
>
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/t
>ags/sql/QueryTag.java,v retrieving revision 1.9
>   retrieving revision 1.10
>   diff -u -r1.9 -r1.10
>   --- QueryTag.java 1 Jun 2002 10:21:14 -0000 1.9
>   +++ QueryTag.java 26 Sep 2002 18:35:23 -0000 1.10
>   @@ -168,6 +168,8 @@
>
>            log.debug( "About to lookup connection" );
>
>   +        ResultSet rs = null;
>   +        Statement statement = null;
>            try {
>                conn = getConnection();
>
>   @@ -202,14 +204,14 @@
>                    log.debug( "About to execute query: " + sqlStatement );
>                }
>
>   -            ResultSet rs = null;
>                if ( hasParameters() ) {
>                    PreparedStatement ps =
> conn.prepareStatement(sqlStatement); setParameters(ps);
>   +                statement = ps;
>                    rs = ps.executeQuery();
>                }
>                else {
>   -                Statement statement = conn.createStatement();
>   +                statement = conn.createStatement();
>                    rs = statement.executeQuery(sqlStatement);
>                }
>
>   @@ -220,6 +222,20 @@
>                throw new JellyException(sqlStatement + ": " +
> e.getMessage(), e); }
>            finally {
>   +            if (statement != null) {
>   +                try {
>   +                    statement.close();
>   +                }
>   +                catch (SQLException e) {
>   +                } // Not much we can do
>   +            }
>   +            if (rs != null) {
>   +                try {
>   +                    rs.close();
>   +                }
>   +                catch (SQLException e) {
>   +                } // Not much we can do
>   +            }
>                if (conn != null && !isPartOfTransaction) {
>                    try {
>                        conn.close();


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to