Sets the value of the designated parameter with the given object.
The JDBC specification specifies a standard mapping from
Java Object
types to SQL types. The given argument
will be converted to the corresponding SQL type before being
sent to the database.
Note that this method may be used to pass database-
specific abstract data types, by using a driver-specific Java
type.
If the object 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.
This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.
Note: Not all databases allow for a non-typed Null to be sent to
the backend. For maximum portability, the setNull
or the
setObject(String parameterName, Object x, int sqlType)
method should be used
instead of setObject(String parameterName, Object x)
.
parameterName | the name of the parameter | |
x | the object containing the input parameter value |
SQLException | if parameterName does not correspond to a named
parameter; if a database access error occurs,
this method is called on a closed CallableStatement or if the given
Object parameter is ambiguous | |
SQLFeatureNotSupportedException | if the JDBC driver does not support this method |
getObject
Diagram: Statement