setBlob(int parameterIndex, InputStream inputStream, long length)

Syntax:

void setBlob(int parameterIndex,
             InputStream inputStream,
             long length)
             throws SQLException

Description:

Sets the designated parameter to a InputStream object. The inputstream must contain the number of characters specified by length otherwise a SQLException will be generated when the PreparedStatement is executed. This method differs from the setBinaryStream (int, InputStream, int) method because it informs the driver that the parameter value should be sent to the server as a BLOB. When the setBinaryStream method is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as a LONGVARBINARY or a BLOB.

Parameters:

parameterIndex

index of the first parameter is 1, the second is 2, ...

inputStream

An object that contains the data to set the parameter value to.

length

the number of bytes in the parameter data.

Throws:

SQLException - if a database access error occurs, parameterIndex is less than 1 or greater than the number of parameters, length is less than 0, or the prepared statement has been closed

Reference:

For more information, reference JDBC documentation for: PreparedStatement.setBlob(int, InputStream, long)