tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Coleman <don.cole...@emax.com>
Subject DBtag problem using PreparedStatement
Date Fri, 19 Oct 2001 19:10:39 GMT
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" 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