Aracılığıyla paylaş


IPreparedStatement.SetObject Method

Definition

Overloads

SetObject(Int32, Object, Int32, Int32)

Sets the value of the designated parameter with the given object.

SetObject(Int32, Object)

Sets the value of the designated parameter using the given object.

SetObject(Int32, Object, Int32)

Sets the value of the designated parameter with the given object.

SetObject(Int32, Object, Int32, Int32)

Sets the value of the designated parameter with the given object.

[Android.Runtime.Register("setObject", "(ILjava/lang/Object;II)V", "GetSetObject_ILjava_lang_Object_IIHandler:Java.Sql.IPreparedStatementInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public void SetObject (int parameterIndex, Java.Lang.Object? x, int targetSqlType, int scaleOrLength);
[<Android.Runtime.Register("setObject", "(ILjava/lang/Object;II)V", "GetSetObject_ILjava_lang_Object_IIHandler:Java.Sql.IPreparedStatementInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member SetObject : int * Java.Lang.Object * int * int -> unit

Parameters

parameterIndex
Int32

the first parameter is 1, the second is 2, ...

x
Object

the object containing the input parameter value

targetSqlType
Int32

the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.

scaleOrLength
Int32

for java.sql.Types.DECIMAL or java.sql.Types.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.

Attributes

Exceptions

if a database error happens.

Remarks

Sets the value of the designated parameter with the given object. The second argument must be an object type; for integral values, the java.lang equivalent objects should be used.

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.

Added in 1.6.

Java documentation for java.sql.PreparedStatement.setObject(int, java.lang.Object, int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SetObject(Int32, Object)

Sets the value of the designated parameter using the given object.

[Android.Runtime.Register("setObject", "(ILjava/lang/Object;)V", "GetSetObject_ILjava_lang_Object_Handler:Java.Sql.IPreparedStatementInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public void SetObject (int parameterIndex, Java.Lang.Object? x);
[<Android.Runtime.Register("setObject", "(ILjava/lang/Object;)V", "GetSetObject_ILjava_lang_Object_Handler:Java.Sql.IPreparedStatementInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member SetObject : int * Java.Lang.Object -> unit

Parameters

parameterIndex
Int32

the first parameter is 1, the second is 2, ...

x
Object

the object containing the input parameter value

Attributes

Exceptions

if a database error happens.

Remarks

Sets the value of the designated parameter using the given object. The second parameter must be of type Object; therefore, the java.lang equivalent objects should be used for built-in types.

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 datatabase- 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, RowId, SQLXML or Array, the driver should pass it to the database as a value of the corresponding SQL type.

<b>Note:</b> Not all databases allow for a non-typed Null to be sent to the backend. For maximum portability, the setNull or the setObject(int parameterIndex, Object x, int sqlType) method should be used instead of setObject(int parameterIndex, Object x).

<b>Note:</b> 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.

Java documentation for java.sql.PreparedStatement.setObject(int, java.lang.Object).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SetObject(Int32, Object, Int32)

Sets the value of the designated parameter with the given object.

[Android.Runtime.Register("setObject", "(ILjava/lang/Object;I)V", "GetSetObject_ILjava_lang_Object_IHandler:Java.Sql.IPreparedStatementInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public void SetObject (int parameterIndex, Java.Lang.Object? x, int targetSqlType);
[<Android.Runtime.Register("setObject", "(ILjava/lang/Object;I)V", "GetSetObject_ILjava_lang_Object_IHandler:Java.Sql.IPreparedStatementInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member SetObject : int * Java.Lang.Object * int -> unit

Parameters

parameterIndex
Int32

the first parameter is 1, the second is 2, ...

x
Object

the object containing the input parameter value

targetSqlType
Int32

the SQL type (as defined in java.sql.Types) to be sent to the database

Attributes

Exceptions

if a database error happens.

Remarks

Sets the value of the designated parameter with the given object. This method is like the method setObject above, except that it assumes a scale of zero.

Java documentation for java.sql.PreparedStatement.setObject(int, java.lang.Object, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to