tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <>
Subject Re: question about standard taglib sql
Date Tue, 14 Mar 2006 21:20:45 GMT
Kris Schneider wrote:
> Jerry wrote:
>> Steven F. Bell <sbell <at>> writes:
>>> Hello,
>>> I am using the standard taglib sql tag to query a database and large 
>>> text fields are coming back like:
>>> net.sourceforge.jtds.jdbc.ClobImpl <at> 94aa42
>>> What could be causing this, and is there any means to correct it, and 
>>> get the proper text back?
> JSTL will use ResultSet.getObject to retrieve your results. In some 
> cases, this will result in a Clob. If you're using JSP 2.0, you might 
> consider creating an EL function to process the Clob into a string. Or 
> you could take a bean-based approach that will also work with earlier 
> version of JSP. Obviously, a scriptlet will also get the job done. The 
> simplest way to convert a Clob into a String is:
> long length = theClob.length();
> String s = theClob.getSubString(0, (int)length);

Sorry, I think that should be:

String s = theClob.getSubString(1, (int)length);

> Of course, that might not work depending on the length of the Clob, so 
> there are other ways to stream the Clob data:
> Reader in = theClob.getCharacterStream();
> ...
>>> Also, the results in the tag are alphabetical a-z, can this order be 
>>> changed around to match the field order in the database?
> You might want to look at using Result.getRowsByIndex instead of 
> Result.getRows to iterate through your results:
> <c:forEach var="row" items="${results.rowsByIndex}">
>   <c:forEach var="col" items="${row}">
> Result.getRowsByIndex returns an Object[][] instance where the first 
> dimension is a row index and the second dimension is a column index.
> I hope that's right, it's been a while since I've been able to play with 
> JSP/JSTL stuff...
>> Hi,
>> I had the same problem because i used the datatype ntext of text of a 
>> sql server
>> database.
>> Using varchar instead of text resolved my problem.
>> Hope this helps,
>> Jerry

Kris Schneider <>
D.O.Tech       <>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message