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 RE: DBtag problem using PreparedStatement
Date Fri, 19 Oct 2001 20:54:17 GMT
Steve,
Thanks for the info.  length(sku) returns 4.  This is an Oracle 8.1.7 table
and the column is CHAR(4).

The wierd thing is that in sqlplus and as Statements all of these queries
work 
SELECT * FROM deo_product where sku = 'K17' 
SELECT * FROM deo_product where sku = 'K17 ' 
SELECT * FROM deo_product where sku = 'K17  ' 

But when using a PreparedStatement all the spaces are necessary.
SELECT * FROM deo_product where sku = 'K17 '

I'm going to try the OCI JDBC Drivers and see it the fixes my problem.

-----Original Message-----
From: Mader, Steve [mailto:steve.mader@eds.com]
Sent: Friday, October 19, 2001 4:04 PM
To: taglibs-user@jakarta.apache.org
Subject: RE: DBtag problem using PreparedStatement


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" 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