background image
<< INOUT parameter type correspondence | java.sql.ResultSet interface >>

java.sql.PreparedStatement interface

<< INOUT parameter type correspondence | java.sql.ResultSet interface >>
Derby Reference Manual
313
Register the output type of the parameter before executing the call. For INOUT
parameters, it is good practice to register the output parameter before setting its input
value.
java.sql.PreparedStatement interface
Derby provides all the required JDBC type conversions and additionally allows use of
the individual setXXX methods for each type as if a setObject(Value, JDBCTypeCode)
invocation were made.
This means that setString can be used for any built-in target type.
The setCursorName method can be used on a PreparedStatement prior to an execute
request to control the cursor name used when the cursor is created.
Prepared statements and streaming columns
setXXXStream requests stream data between the application and the database.
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. Derby 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
Note: Derby does not support the setNCharacterStream method or the deprecated
setUnicodeStream method.
JDBC 3.0 requires that you specify the length of the stream, and Derby enforces this
requirement if your application runs on JDK 5 or earlier. If your application runs on
JDK 6, Derby exposes a JDBC 4.0 implementation, which lets you use the streaming
interfaces without having to specify the stream length. 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
Mapping of java.sql.Types to SQL types
.
Table 123.
Streamable JDBC data types
Column
Data Type
Corresponding
Java Type
AsciiStream CharacterStreamBinaryStream
CLOB
java.sql.Clob
Yes
Yes
No
CHAR
None
Yes
Yes
No
VARCHAR
None
Yes
Yes
No
LONGVARCHAR
None
Preferred
Preferred
No