You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Vadim Gritsenko <va...@reverycodes.com> on 2006/10/16 14:55:41 UTC
Re: svn commit: r464376 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/databases/java/org/apache/cocoon/transformation/SQLTransformer.java
status.xml
antonio@apache.org wrote:
> @@ -1533,14 +1659,21 @@
> if (object instanceof Clob && this.clobEncoding != null) {
> Clob clob = (Clob) object;
> StringBuffer buffer = new StringBuffer();
> - InputStream is = clob.getAsciiStream();
> try {
> - byte[] bytes = new byte[BUFFER_SIZE];
> - int n;
> - while ((n = is.read(bytes)) > -1) {
> - buffer.append(new String(bytes, 0, n, this.clobEncoding));
> - }
> - } catch (IOException e) {
> + int blocksize = BUFFER_SIZE;
> + long length = clob.length();
> + long nMax = length / blocksize;
> + for (int n = 0; n < nMax; n++) {
> + String sText = clob.getSubString(n*blocksize+1, blocksize);
> + buffer.append( sText);
> + }
> + //Read the last block
> + int lastblocksize = (int)length%blocksize;
> + if (lastblocksize > 0) {
> + String sText = clob.getSubString(nMax*blocksize+1, lastblocksize);
> + buffer.append( sText);
> + }
> + } catch (Exception e) {
> throw new SQLException("Error reading stream from CLOB");
> }
> return buffer.toString();
Antonio,
Please revert. This code was specifically present for the purpose of backward
compatibility, as it is stated in the comment. Correctly functioning new code is
in the very next if() statement, implemented via getCharacterStream.
Vadim