Редагувати

Поділитися через


setObject Method (int, java.lang.Object)

Download JDBC driver

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

Syntax

  
public final void setObject(int index,  
                            java.lang.Object obj)  

Parameters

index

An int that indicates the parameter number.

obj

An object.

Exceptions

SQLServerException

Remarks

This setObject method is specified by the setObject method in the java.sql.PreparedStatement interface.

Before calling this setObject method, the application might set the specified parameter by using one of the following methods:

  • The set<Type> methods of the SQLServerPreparedStatement class or the SQLServerCallableStatement class

  • The setNull methods of the SQLServerPreparedStatement class or the SQLServerCallableStatement class

  • The registerOutParameter method of the SQLServerCallableStatement class

In such a case, the type of the parameter is automatically set. If the application calls this setObject method with an obj value NULL, the driver assumes that the type of the parameter is one that is set by the previously called method.

If the obj value is NULL and no type information for that parameter can be determined, this setObject method converts the specified parameter to a CHAR before sending it to the database.

Beginning with SQL Server JDBC Driver 3.0, the behavior of this method is modified by the sendTimeAsDatetime connection property (Setting the Connection Properties) and SQLServerDataSource.setSendTimeAsDatetime.

For more information, see Configuring How java.sql.Time Values are Sent to the Server.

See Also

setObject Method (SQLServerPreparedStatement)
SQLServerPreparedStatement Members
SQLServerPreparedStatement Class