Hi,all:
    In SQLTransformer using such code to get current string from CLOB:
    InputStream inputStream = clob.getAsciiStream();
    byte[] readByte = new byte[numberOfChar];
    StringBuffer buffer = new StringBuffer();
    try {
     while(inputStream.read(readByte) > -1) {
      String string = new String(readByte, clobEncoding);
      buffer.append(string);
     }
    } catch(java.io.IOException ioException) {
     throw new SQLException("Error reading stream from CLOB");
    }
    retval = buffer.toString();

    clobEncoding is set by parameter clob-encoding

    But when I use oracle 9i(8i) NCLOB or CLOB to store Chinese string,this code 
doesn't work though I try many encoding.I think the key is clob.getAsciiStream().I 
don't know the problem is the jdbc driver's or getAsciiStream just can't deal with 
double bytes encoding.This code works for me when using oracle NCLOB:
        Reader bodyReader = null;
    try {
     bodyReader = rs.getCharacterStream(i);
     if (bodyReader == null) {
      return null;
     }
     char [] buf = new char[256];
     int len;
     StringWriter out = new StringWriter(256);
     while ((len = bodyReader.read(buf)) >= 0) {
      out.write(buf, 0, len);
     }
     
     retval = out.toString();
     out.close();
    }
    catch (Exception e) {
     e.printStackTrace();
     throw new SQLException("Failed to load text field");
    }
    finally {
     try { bodyReader.close(); }
     catch(Exception e) { }
    }
    I don't know if this will help to make SQLTransformer get CLOB more portable.

Roy Huang

Reply via email to