Hi all,

I think that it's not really a big issue.  The JDBC tags don't actually
use the getXXX methods for finding column names; they do their own looping
and matching through the columns to find the column index.  And since the
JavaDocs of ResultSet say:

  Column names used as input to getXXX methods are case insensitive. 

I think we're emulating the behaviour that users expect.

Using column names is probably not a great practice in many situations
anyway.  We added the feature because a few users really wanted it and
Marius provided a patch, but it's a little risky because, when multiple
columns have the same name (in join for example) then, as per the spec,
the first column by that name is returned.  This can cause problems if
you don't watch your syntax.  Column indices are safer in my opinion.

As an aside, when we finish our preparations for versioned releases, I'm
changing the name of these tags to "DBTags".  JDBC is a Sun trademark, and
sooner or later they'll come after us for using the trademark in a product
name.  Pierre, how is the dashboard proposal coming?

- Morgan


On Mon, 23 Apr 2001, Glenn Nielsen wrote:

> If a dB has case insensitive column names, shouldn't that be implemented in
> the JDBC driver, not in the JDBC tag lib?  As Nick states, some dB's do support
> case sensitve names.
> 
> Regards,
> 
> Glenn
> 
> Perhaps the change Morgan did below should be reverted.
> 
> Glenn
> 
> Nick Christopher wrote:
> > 
> > Newer sybase's are case sensitive with regards to object names (i.e. 
>tables/cols/indexes).
> > 
> > Morgan Delagrange wrote:
> > 
> > > Good catch, I believe you are correct.  I'll patch it up today.
> > >
> > > - Morgan
> > >
> > > On Thu, 19 Apr 2001, Dave Dribin wrote:
> > >
> > > > Hello,
> > > >
> > > > I was just playing around with the 04/19 version of the JDBC tag
> > > > library and trying to run the example pages.  I am using Oracle as a
> > > > back-end database and using a JNDI named datasource under Resin 1.2.3.
> > > > I am getting the following exception while running the jndijdbc.jsp
> > > > page:
> > > >
> > > > javax.servlet.jsp.JspTagException: Could not find column named id
> > > >         at 
>org.apache.taglibs.jdbc.resultset.BaseGetterTag.getColumnNumber(BaseGetterTag.java:245)
> > > >         at 
>org.apache.taglibs.jdbc.resultset.BaseGetterTag.getPosition(BaseGetterTag.java:111)
> > > >         at 
>org.apache.taglibs.jdbc.resultset.GetNumberTag.doStartTag(GetNumberTag.java:149)
> > > >
> > > > I tracked down the problem to this line in the JSP:
> > > >
> > > >       <td><sql:getNumber colName="id" format="CURRENCY" locale="en_GB"/></td>
> > > >
> > > > Now, it turns out that if I use all caps for the column name like "ID"
> > > > rather than "id" it works.  I think this is due to the fact that I am
> > > > running Oracle and it is probably passing back the column names in all
> > > > caps regardless of how the table was created.  However, colName should
> > > > probably be doing a case insensitive compare.  I narrowed it down to
> > > > this bit of code in BaseGetterTag.java:
> > > >
> > > >    236        for (int i = 1; i <= cntColumn; i++) {
> > > >    237          if (strName.equals (meta.getColumnName (i))) {
> > > >    238            return i;
> > > >    239          }
> > > >    240        }
> > > >
> > > > Changing line 237 to use String.equalsIgnoreCase() should fix it.  SQL
> > > > is not case sensitive, right?
> > > >
> > > > -Dave
> > > >
> 
> -- 
> ----------------------------------------------------------------------
> Glenn Nielsen             [EMAIL PROTECTED] | /* Spelin donut madder    |
> MOREnet System Programming               |  * if iz ina coment.      |
> Missouri Research and Education Network  |  */                       |
> ----------------------------------------------------------------------
> 


Reply via email to