Table 7-2 lists the data types supported by the Oracle driver and describes how they are mapped to the JDBC data types.
Oracle9i and higher supports the following date/time data types:
Table 7-3 describes the session parameters the Oracle driver sets at connection time that affect how the driver supports date/time data types.
When retrieving TIMESTAMP WITH LOCAL TIME ZONE columns, the value returned to the user is converted to the time zone specified by the TIME_ZONE session parameter.
When retrieving TIMESTAMP WITH TIME ZONE values as a string (using resultSet.getString(), for example), the value is returned as the string representation of the timestamp including time zone information. The string representation is formatted as:
By default, retrieving TIMESTAMP WITH TIME ZONE values as a timestamp (using resultSet.getTimeStamp, for example) is not supported because the time zone information stored in the database would be lost when the data is converted to a timestamp. To provide backward compatibility with existing applications, you can use the FetchTSWTZasTimestamp property to allow TIMESTAMP WITH TIME ZONE values to be returned as a timestamp. The default value of the FetchTSWTSasTimestamp property is
false, which disables retrieving TIMESTAMP WITH TIME ZONE values as timestamps.
Oracle8i and higher supports the following collection data types:
The Oracle VARRAY and TABLE data types map to the JDBC ARRAY data type. To use these data types as a parameter, an array must be created using the createArray() method of the ExtConnection interface. See
“ExtConnection Interface” for more information about this method.
If you want more accurate metadata information for either of these data types, set the CatalogOptions connection property to
8, but be aware that this can negatively affect performance. See the description of CatalogOptions in
“Connection Properties” for details.
The Oracle OBJECT data type maps to the JDBC STRUCT data type. To use this data type as a parameter, the parameter value must be created using the createStruct() method of the Connection interface. See
“Connection” for more information about this method.
For Oracle9i and higher, the Oracle driver supports the Oracle XMLType data type. Which JDBC data type the XMLType data type is mapped to depends on whether the JDBCBehavior property is set. If JDBCBehavior=0, XML data is mapped to SQLXML or CLOB, depending on which JVM your application is using. The driver maps the XMLType data type to the JDBC SQLXML data type if your application is using Java SE 6 or higher. If your application is using an earlier JVM, the driver maps the XMLType data type to the JDBC CLOB data type.
NOTE: The conversion caused by using the getAsciiStream() method may create XML that is not well-formed because the content encoding is not the default encoding and does not contain an XML declaration specifying the content encoding. Do not use the getAsciiStream() method if your application requires well-formed XML.
When inserting to or updating XMLType columns, the data to be inserted or updated must be the XMLType data type. Oracle provides the xmltype() function to construct an XMLType data object. The xmlData argument of the xmltype() function can be specified as a string literal or a parameter marker. If specified as a parameter marker, the parameter value can be set using the following methods:
The driver converts the character representation of the data to the XML character set used by the database server and sends the converted XML data to the server. The driver does not parse or remove any XML processing instructions.
REF CURSOR is the Oracle data type for a cursor variable. Because JDBC does not support a cursor variable data type, the Oracle driver returns REF CURSOR output parameters and return values to the application as result sets. The Oracle driver converts the REF CURSOR data to a result set that can be returned using getResultSet() or getMoreResults(). Because REF CURSOR data is returned as result sets and not as output parameters, REF CURSOR output parameters are not included in results from DatabaseMetaData.getProcedureColumns() calls.
In your application, omit any parameter markers for the REF CURSOR as shown in the following examples and do not declare an output parameter for the REF CURSOR. These examples reference the following stored procedure definition:
PROCEDURE selectEmployeeManager(empId IN INT, empCursor OUT EmpCurTyp,
mgrCursor out EmpCurTyp);