checkSetParameterIndex(parameterIndex, true);
if (parameterTypes[parameterIndex - 1].typeCode == Types.SQL_CLOB) {
try {
if (length < 0) {
CharArrayWriter output;
output = new CharArrayWriter(reader);
JDBCClob clob = new JDBCClob(output.toString());
setClobParameter(parameterIndex, clob);
return;
}
} catch (IOException e) {
throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR,
e.toString());
}
streamLengths[parameterIndex - 1] = length;
setParameter(parameterIndex, reader);
return;
}
try {
if (length > Integer.MAX_VALUE) {
String msg = "Maximum Clob input length exceeded: " + length;
throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR, msg);
}
CharArrayWriter writer;
if (length < 0) {
writer = new CharArrayWriter(reader);
} else {
writer = new CharArrayWriter(reader, (int) length);
}
setParameter(parameterIndex, writer.toString());
} catch (IOException e) {
throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR,
e.toString());
}
}