1.1.1

Table Of Contents
Prepared Statements and Streaming Columns
setXXXStream requests stream data between the client and the server. 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. SQLFire supports the three types of streams that the
JDBC API provides:
setBinaryStream Use for streams that contain uninterpreted bytes.
setAsciiStream Use for streams that contain ASCII characters.
setUnicodeStream Use for streams that contain Unicode characters.
The stream object passed to these three methods can be either a standard Java stream object or the user's own
subclass that implements the standard java.io.InputStream interface. According to the JDBC standard,
streams can be stored only in columns with the data types shown in the following table.
Streamable JDBC Data Types
BinaryStreamUnicodeStreamAsciiStreamCorresponding Java TypeColumn Data Type
'xxjava.sql.ClobCLOB
'xx'CHAR
'xx'VARCHAR
'XX'LONGVARCHAR
xxx'BINARY
xxxjava.sql.BlobBLOB
xxx'VARBINARY
Xxx'LONGVARBINARY
Note:
A large X indicates the preferred target data type for the type of stream. See Mapping java.sql.Types to SQL
Types on page 357.
If the stream is stored in a column of a type other than LONG VARCHAR or LONG VARCHAR FOR BIT
DATA, the entire stream must be able to t into memory at one time. Streams stored in LONG VARCHAR
and LONG VARCHAR FOR BIT DATA columns do not have this limitation.
Streams cannot be stored in columns of the other built-in data types or columns of user-dened data types.
Example
The following example shows how a user can store a streamed java.io.File in a LONG VARCHAR column:
Statement s = conn.createStatement();
s.executeUpdate("CREATE TABLE atable (a INT, b LONG VARCHAR)");
conn.commit();
java.io.File file = new java.io.File("derby.txt");
int fileLength = (int) file.length();
// first, create an input stream
java.io.InputStream fin = new java.io.FileInputStream(file);
PreparedStatement ps = conn.prepareStatement("INSERT INTO atable VALUES (?,
?)");
ps.setInt(1, 1);
// set the value of the input parameter to the input stream
vFabric SQLFire User's Guide362
vFabric SQLFire Reference