commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Graham <grahamdavid1...@yahoo.com>
Subject Re: [DBUtils] QueryRunner.fillStatement is not static
Date Thu, 07 Jul 2005 16:36:05 GMT
The problem is with the setNull() handling.  In the latest code we're
using Types.VARCHAR because OTHER did not work for all drivers.  In fact,
the primary reason the method is protected is so you can override the null
behavior if it doesn't work for your driver.

We could add a DbUtils.fillStatement() static method.  Of course, this
wouldn't work for everyone and wouldn't be customizable because it's
static.  If you really want this method please open a Bugzilla enhancement
ticket and attach a cvs diff -u formatted patch.

http://issues.apache.org/bugzilla/

Thanks,
David


--- Elifarley <elifarley@yahoo.com> wrote:

> Hmm... I see.
> 
> And what about this:
> 
> -- 
>   protected void fillStatement(PreparedStatement stmt, Object[] params)
>   throws SQLException {
>     defaultFillStatement(stmt, params);
>   }
> 
> 
>   public static void defaultFillStatement(PreparedStatement stmt,
> Object[] params)
>   throws SQLException {
> 
>     if (params == null) {
>       return;
>     }
> 
>     for (int i = 0; i < params.length; i++) {
>       if (params[i] != null) {
>           stmt.setObject(i + 1, params[i]);
>       } else {
>           stmt.setNull(i + 1, Types.OTHER);
>       }
>     }
> 
>   }
> --
> 
> Doing so still allows the method to be subclassed and does not force me
> to
> create an instance to use this functionality.
> 
> Cheers,
> Elifarley
> 
> On Wed, 06 Jul 2005 17:36:35 -0700, David Graham wrote:
> 
> > Referencing instance state is not a worthy criteria for making a
> method
> > static.  Changing fillStatement() to static would break the many
> > subclasses that override this method to provide customized behavior.
> > Static methods cannot be overridden.
> > 
> > David
> > 
> > 
> > --- Elifarley <elifarley@yahoo.com> wrote:
> > 
> >> The method 'QueryRunner.fillStatement' is not static even though no
> >> instance state is referenced. Could it be officially changed into a
> >> static
> >> method ?
> >> 
> >> (I need to use this functionality but I don't want to instantiate
> this
> >> class just to use this method).
> >> 
> >> Regards,
> >> Elifarley
> > 

Get Firefox!
http://www.mozilla.org/firefox/


		
____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items.  
http://auctions.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message