[EMAIL PROTECTED] 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