8.5.41 getObject(int columnIndex)
- Organization of this subsection
(1) Function
This method acquires as Object in the Java programming language the value in a specified column in the current row of the ResultSet object. The column whose value is to be acquired is specified in the argument.
(2) Format
public synchronized Object getObject(int columnIndex) throws SQLException
(3) Arguments
- int columnIndex
-
Specifies a column number.
(4) Return value
This method returns the column value as a Java object.
This Java object has the default Java object type that corresponds to the column's SQL type based on the mapping of built-in types specified in the JDBC specifications.
The following table shows the relationship between the retrieval result and the return value.
HADB data type |
Retrieval result |
Return value |
---|---|---|
CHAR VARCHAR |
Null value |
null |
Other than the above |
retrieval-result |
|
SMALLINT |
Null value |
null |
Other than the above |
Integer object created by using the retrieval result |
|
INTEGER |
Null value |
null |
Other than the above |
Long object created by using the retrieval result |
|
DECIMAL |
Null value |
null |
Other than the above |
retrieval-result |
|
DOUBLE PRECISION |
Null value |
null |
Other than the above |
Double object created by using the retrieval result |
|
DATE |
Null value |
null |
Other than the above |
java.sql.Date object created by using the retrieval result |
|
TIME |
Null value |
null |
Other than the above |
java.sql.Time object created by using the retrieval result |
|
TIMESTAMP |
Null value |
null |
Other than the above |
java.sql.Timestamp object created by using the retrieval result |
|
BINARY VARBINARY |
Null value |
null |
Other than the above |
retrieval-result |
|
ROW |
Non-null value#1 |
retrieval-result |
BOOLEAN#2 |
Null value |
null |
Non-null value |
Boolean object created by using the retrieval result |
- #1
-
The retrieval result will never be the null value.
- #2
-
BOOLEAN-type data exists when the ResultSet object was created from DatabaseMetadata.
(5) Exceptions
The JDBC driver throws an SQLException in the following cases:
-
This ResultSet object is closed.
This includes the case where the ResultSet object was closed because the Statement object that created this ResultSet object was closed.
-
The Connection used to create the Statement object that created this ResultSet object has been closed.
-
The ResultSet object has become invalid due to transaction settlement.
-
A nonexistent column number was specified.
-
An error occurred in the JDBC driver.