tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mader, Steve" <steve.ma...@eds.com>
Subject RE: DBtag problem using PreparedStatement
Date Fri, 19 Oct 2001 20:04:29 GMT
What's in the sku field after the '7' ?  Maybe there is space or spaces
there you're not seeing.  Does it work if you use 'K17%' ?  If so, that
would suggest to me that there are spaces (or something else) in that field
after the 7.

-----Original Message-----
From: Don Coleman [mailto:don.coleman@emax.com]
Sent: Friday, October 19, 2001 3:11 PM
To: 'taglibs-user@jakarta.apache.org'
Subject: DBtag problem using PreparedStatement



I am having a problem with PreparedStatments and DB-tags 1.0 Beta 1 

The following page (see below for full page) will not return any results
when using this query 
    <sql:query> 
      SELECT sku, product_ds FROM deo_product where sku = ? 
    </sql:query> 

    <sql:setColumn position="1">K17</sql:setColumn> 

But if I use like it works fine. 
    <sql:query> 
      SELECT sku, product_ds FROM deo_product where sku like ? 
    </sql:query> 

    <sql:setColumn position="1">K1%</sql:setColumn> 

I'm not sure what I am doing wrong.  I've tried adding quotes and using
<sql:escapeSql> but I can't get this to work. 

Does anyone have any suggestions? 


<%@ taglib uri=" http://jakarta.apache.org/taglibs/dbtags
<http://jakarta.apache.org/taglibs/dbtags> " prefix="sql" %> 

<%-- open a database connection --%> 
<sql:connection id="conn" jndiName="java:/comp/env/jdbc/deo"/> 

<%-- print the rows in an HTML table --%> 
<table> 
<sql:preparedStatement id="stmt" conn="conn"> 

    <sql:query> 
      SELECT sku, product_ds FROM deo_product where sku = ? 
    </sql:query> 

    <sql:setColumn position="1">K17</sql:setColumn> 

    <%-- loop through the rows of your query --%> 
    <sql:resultSet id="rs"> 
    <tr> 
      <td><sql:getColumn position="1"/></td> 
      <td><sql:getColumn position="2"/></td> 
    </tr> 
    </sql:resultSet> 

</sql:preparedStatement> 
</table> 

<!-- close the connection --> 
<sql:closeConnection conn="conn"/> 


Mime
View raw message