包可用:  public static void setLargeTextField(PreparedStatement pstmt,
        int parameterIndex, String value) throws SQLException
{
    
        Reader bodyReader = null;
        try {
            bodyReader = new StringReader(value);
            pstmt.setCharacterStream(parameterIndex, bodyReader, value.length());
        }
        catch (Exception e) {
            e.printStackTrace();
            throw new SQLException("Failed to set text field.");
        }
        // Leave bodyReader open so that the db can read from it. It *should*
        // be garbage collected after it's done without needing to call close.}

解决方案 »

  1.   

    到底是用setCharacterStream还是setClob啊?
      

  2.   

    使用biye[]好像可以,用setClob,读代码如下
    getAsciiStream materializes the CLOB value as a byte stream containing Ascii bytes Clob notes = rs.getClob("NOTES");
    java.io.InputStream in = notes.getAsciiStream();
    byte b = in.read();
    // in contains the characters in the CLOB value designated by
    // notes as Ascii bytes; b contains the first character as an Ascii 
    // byte
    getCharacterStream materializes the CLOB value as a stream of Unicode characters java.io.Reader reader = notes.getCharacterStream();
    int c = Reader.read();
    // c contains the first character in the CLOB that notes designates
    getSubString materializes all or part of the CLOB value as a String object String substring = notes.getSubString(10, 5);
    // substring contains five characters, starting with the tenth
    // character of the CLOB value that notes designates
    long len = notes.length();
    String substring = notes.getSubString(1, len);
    // substring contains all of the characters in the CLOB object that
      

  3.   

    一个恶心的男人告诉我了,谢谢楼上的两位Clob clob = rs.getClob("content");
    char[] chr = new char[Integer.parseInt(String.valueOf(clob.length))];
    Read read = clob.getCharacterStream();
    read.read(chr);
    String str = new String(chr);