JDBC allows an IN parameter to be set to a Java input stream for
passing in large amounts of data in smaller chunks. When the statement is
run, the JDBC driver makes repeated calls to this input stream.
supports
the following JDBC stream methods for PreparedStatement objects:
- setBinaryStream
Use for streams that contain uninterpreted bytes
- setAsciiStream
Use for streams that contain ASCII characters
- setCharacterStream
Use for streams that contain characters
does not support
the setNCharacterStream method or the deprecated setUnicodeStream
method.
These methods do not require that you specify the length of the
stream. However, if you omit the length argument when the stream object is a LOB
greater than a single page in size, performance will be impaired if you later
retrieve the length of the LOB. If you are simply inserting or reading data,
performance is unaffected.
The stream object passed to setBinaryStream and setAsciiStream
can be either a standard Java stream object or the user's own subclass that
implements the standard java.io.InputStream interface. The object passed
to setCharacterStream must be a subclass of the abstract
java.io.Reader class.
According to the JDBC standard, streams can be stored only in columns with
the data types shown in the following table. The word "Preferred" indicates the
preferred target data type for the type of stream. See
.
Streamable JDBC data types
For each JDBC column data type, this table lists the corresponding Java data type (if any) and shows whether each of the stream types can be stored in columns of that type.
Column Data Type
Corresponding Java Type
AsciiStream
CharacterStream
BinaryStream
CLOB
java.sql.Clob
Yes
Yes
No
CHAR
None
Yes
Yes
No
VARCHAR
None
Yes
Yes
No
LONGVARCHAR
None
Preferred
Preferred
No
BINARY
None
Yes
Yes
Yes
BLOB
java.sql.Blob
Yes
Yes
Yes
VARBINARY
None
Yes
Yes
Yes
LONGVARBINARY
None
Yes
Yes
Preferred
Streams cannot be stored in columns of the other built-in data types or
columns of user-defined data types.