getObject Method (java.lang.String) (SQLServerResultSet)
Gets the value of the designated column name in the current row of this SQLServerResultSet object as an object in the Java programming language.
Syntax
public java.lang.Object getObject(java.lang.String columnName)
Parameters
A String that contains the column name.
Return Value
An Object value.
Exceptions
Remarks
This getObject method is specified by the getObject method in the java.sql.ResultSet interface.
This method will return the value of the given column as a Java object. The type of the Java object will be the default Java object type corresponding to the SQL type of the column, following the mapping for built-in types that is specified in the JDBC specification. If the value is an SQL NULL, the driver returns a Java null.
This method can also be used to read database-specific abstract data types. In the JDBC 2.0 API, the behavior of the getObject method is extended to materialize data of SQL user-defined types. When a column contains a structured or distinct value, the behavior of this method is as if it were a call to getObject(columnIndex, this.getStatement().getConnection().getTypeMap()) .
Beginning in the SQL Server JDBC Driver 3.0:
- A value of type date will be returned as a java.sql.Date object.
- A value of type time will be returned as a java.sql.Time object.
- A value of type datetime2 will be returned as a java.sql.Timestamp object.
- A value of type datetimeoffset will be returned as a microsoft.sql.DateTimeOffset object.
Метод getObject (java.lang.String) (SQLServerResultSet)
Возвращает значение имени заданного столбца в текущей строке этого объекта SQLServerResultSet в виде объекта на языке программирования Java.
Синтаксис
public java.lang.Object getObject(java.lang.String columnName)
Параметры
Значение типа String, содержащее имя столбца.
Возвращаемое значение
Значение Object.
Исключения
Remarks
Этот метод getObject определен с помощью метода getObject в интерфейсе java.sql.ResultSet.
Этот метод вернет значение данного столбца в виде объекта Java. Объект Java будет иметь заданный по умолчанию тип, соответствующий типу SQL Server столбца и сопоставленный встроенным типам, указанным в спецификации JDBC. Если значение SQL NULL, то драйвер вернет значение Java NULL.
Этот метод также может быть использован для чтения абстрактных типов данных, относящихся к базе данных. В API JDBC 2.0 возможности метода getObject расширены и поддерживают материализацию данных определяемых пользователем типов SQL. Если в столбце содержится структурированное или уникальное значение, то выполнение этого метода будет аналогично вызову getObject(columnIndex, this.getStatement().getConnection().getTypeMap()) .
Начиная с версии 3.0 драйвера SQL Server JDBC действуют следующие правила:
- Значение типа date будет возвращаться в виде объекта java.sql.Date.
- Значение типа time будет возвращаться в виде объекта java.sql.Time.
- Значение типа datetime2 будет возвращаться в виде объекта java.sql.Timestamp.
- Значение типа datetimeoffset будет возвращаться в виде объекта microsoft.sql.DateTimeOffset.