checkSetParameterIndex(parameterIndex, true);
if (parameterTypes[parameterIndex - 1].typeCode == Types.SQL_BLOB) {
try {
if (length < 0) {
HsqlByteArrayOutputStream output;
output = new HsqlByteArrayOutputStream(x);
JDBCBlob blob = new JDBCBlob(output.toByteArray());
setBlobParameter(parameterIndex, blob);
return;
}
} catch (IOException e) {
throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR,
e.toString());
}
streamLengths[parameterIndex - 1] = length;
setParameter(parameterIndex, x);
return;
}
try {
if (length > Integer.MAX_VALUE) {
String msg = "Maximum Blob input length exceeded: " + length;
throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR, msg);
}
HsqlByteArrayOutputStream output;
if (length < 0) {
output = new HsqlByteArrayOutputStream(x);
} else {
output = new HsqlByteArrayOutputStream(x, (int) length);
}
setParameter(parameterIndex, output.toByteArray());
} catch (IOException e) {
throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR,
e.toString());
}
}