Hello,

Can someone please tell me why the following doesn't work:

<sql:connection id="conn1">
  <sql:url initParameter="dbURL"/> 
  <sql:driver initParameter="mysqlDriver"/>
  <sql:userId initParameter="dbUserId"/> 
  <sql:password initParameter="dbPassword"/>
</sql:connection>

<sql:statement id="stmt1" conn="conn1">
 
        <sql:query>
    select wanted_text from wanted_bios 
    ORDER BY wanted_text
        </sql:query>

<ul>
<sql:resultSet id="rset2">
  <li><sql:getColumn colName="wanted_text"/>

</sql:resultSet>
</ul>
</sql:statement>
<sql:closeConnection conn="conn1"/>

The error I get:

[2001/12/04 11:07:26] null
java.lang.NullPointerException
        at
org.apache.taglibs.dbtags.resultset.BaseGetterTag.getColumnNumber(BaseGetter
Tag.java:239)
        at
org.apache.taglibs.dbtags.resultset.BaseGetterTag.getPosition(BaseGetterTag.
java:111)
        at
org.apache.taglibs.dbtags.resultset.GetColumnTag.doStartTag(GetColumnTag.jav
a:116)
        at _wanted__jsp._jspService(_wanted__jsp.java:211)
        at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
        at com.caucho.jsp.Page.subservice(Page.java:485)
        at
com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:176)
        at com.strangegizmo.filter.GzipFilter.doFilter(GzipFilter.java:117)
        at
com.caucho.server.http.FilterChainFilter.doFilter(FilterChainFilter.java:87)
        at com.caucho.server.http.Invocation.service(Invocation.java:278)
        at
com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
        at
com.caucho.server.http.ServletServer.serviceTop(ServletServer.java:847)
        at
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:213)
        at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
        at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
        at java.lang.Thread.run(Thread.java:484)


It is clear that <sql:getColumn colName="wanted_text"/> is the thing that
gives me the null pointer exception. When there is only one element returned
from the database this doesn't happen, only when two or more elements are
returned. Also <sql:getColumn position="1"/> gives me the same error. 

I've been looking into the code and it happens because _name is null the
second time:

In BaseGetterTag.java:

public int getPosition() throws JspTagException{
    // if the column was set according to its name,
    // figure out its position
    System.out.println("position:" + _position);
    if (_position == -1) {
      _position = getColumnNumber(_name);
    }
    System.out.println("position after if:" + _position);
    return _position;
  }

the second time the code gets executed (second result from the db) _position
= -1 (I don't know why, when  I do getColumn position = 1 I'm not using the
column name at all

So we pass _name (a null value) to that function and in that function we do
: strName.equalsIgnoreCase (meta.getColumnName (i))

(strName == null !!!!)

Can someone from the developers tell me why _name doesn't get properly set
the second time ? Or why the _position doesn't get properly set ? (should be
1, and not -1 logically?)

I'm using Resin 2.0.4 (downloadable at http://www.caucho.com), but Resin
2.0.2 gives the same errors.

Please help me out :-)))

Wim






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

Reply via email to