Sets the value of the designated parameter with the given object.
If the second argument is an InputStream
then the stream
must contain the number of bytes specified by scaleOrLength.
If the second argument is a Reader
then the reader must
contain the number of characters specified
by scaleOrLength. If these conditions are not true the driver
will generate a
SQLException
when the prepared statement is executed.
The given Java object will be converted to the given targetSqlType
before being sent to the database.
If the object has a custom mapping (is of a class implementing the
interface SQLData
),
the JDBC driver should call the method SQLData.writeSQL
to
write it to the SQL data stream.
If, on the other hand, the object is of a class implementing
Ref
, Blob
, Clob
, NClob
,
Struct
, java.net.URL
,
or Array
, the driver should pass it to the database as a
value of the corresponding SQL type.
Note that this method may be used to pass database-specific abstract data types.
The default implementation will throw SQLFeatureNotSupportedException
parameterName | the name of the parameter | |
x | the object containing the input parameter value | |
targetSqlType | the SQL type to be sent to the database. The scale argument may further qualify this type. | |
scaleOrLength | for java.sql.JDBCType.DECIMAL
or java.sql.JDBCType.NUMERIC types ,
this is the number of digits after the decimal point. For
Java Object types InputStream and Reader ,
this is the length
of the data in the stream or reader. For all other types,
this value will be ignored. |
SQLException | if parameterName does not correspond to a named
parameter; if a database access error occurs
or this method is called on a closed CallableStatement or
if the Java Object specified by x is an InputStream
or Reader object and the value of the scale parameter is less
than zero | |
SQLFeatureNotSupportedException | if the JDBC driver does not support the specified targetSqlType |
Diagram: Statement