commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Elifarley <elifar...@yahoo.com>
Subject Re: [DBUtils] QueryRunner.fillStatement is not static
Date Thu, 07 Jul 2005 09:36:03 GMT
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