public static void setLargeTextField(PreparedStatement pstmt, int parameterIndex,
                                         String value) throws SQLException {
        if (isStreamTextRequired()) {
            Reader bodyReader;
            try {
                bodyReader = new StringReader(value);
                pstmt.setCharacterStream(parameterIndex, bodyReader, value.length());
            }
            catch (Exception e) {
                Log.error(e.getMessage(), e);
                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.
        }
        else {
            pstmt.setString(parameterIndex, value);
        }
    }
Sets a large text column in a result set, automatically performing
streaming if the JDBC driver requires it. This is necessary because
different JDBC drivers have different capabilities and methods for
setting large text values.

@param pstmt the PreparedStatement to set the text field in.
@param parameterIndex the index corresponding to the text field.
@param value the String to set.
@throws SQLException if an SQL exception occurs.
xmppserver/src/main/java/org/jivesoftware/database/DbConnectionManager.java