Methods for retrieving and converting data types

With the IMS Universal JDBC driver, you can use the ResultSet interface (java.sql.ResultSet) to retrieve and convert the data from the type that is defined in the database metadata to the type that is required by your Java™ application. Similarly, with the IMS Universal DL/I driver, you can use the Path interface to perform data retrieval and conversion to Java data types.

The following table shows the available get methods in the ResultSet interface (for the IMS Universal JDBC driver) or the Path interface (for the IMS Universal DL/I driver) for accessing data of a certain Java data type.

The "No Truncation or Data Loss" column indicates the data types that are designed to be accessed with the given getXXX method. No truncation or data loss occurs when using those methods for those data types. The data types that are in the Legal without Data Integrity column are all other legal calls; however, data integrity cannot be ensured when using the given getxxx method to access those data types. If a data type is not in either column, using the given getXXX method for that data type will result in an exception.

Table 1. ResultSet.getXXX and Path.getXXX methods to retrieve data types
ResultSet.getXXX Method or Path.getXXX Method Data Type (any not listed result in an exception)
No Truncation or Data Loss Legal without Data Integrity
getByte

TINYINT
UTINYINT

SMALLINT
INTEGER
BIGINT
FLOAT
DOUBLE
BIT
CHAR
VARCHAR
PACKEDDECIMAL1
ZONEDDECIMAL1

getShort

SMALLINT
USMALLINT

TINYINT
INTEGER
BIGINT
FLOAT
DOUBLE
BIT
CHAR
VARCHAR
PACKEDDECIMAL1
ZONEDDECIMAL1

getInt

INTEGER
UINTEGER

TINYINT
SMALLINT
BIGINT
FLOAT
DOUBLE
BIT
CHAR
VARCHAR
PACKEDDECIMAL1
ZONEDDECIMAL1

getLong

BIGINT
UBIGINT

TINYINT
SMALLINT
INTEGER
FLOAT
DOUBLE
BIT
CHAR
VARCHAR
PACKEDDECIMAL1
ZONEDDECIMAL1

getFloat FLOAT

TINYINT
SMALLINT
INTEGER
BIGINT
DOUBLE
BIT
CHAR
VARCHAR
PACKEDDECIMAL1
ZONEDDECIMAL1

getDouble DOUBLE

TINYINT
SMALLINT
INTEGER
BIGINT
FLOAT
BIT
CHAR
VARCHAR
PACKEDDECIMAL1
ZONEDDECIMAL1

getBoolean BIT

TINYINT
SMALLINT
INTEGER
BIGINT
FLOAT
DOUBLE
CHAR
VARCHAR
PACKEDDECIMAL1
ZONEDDECIMAL1

getString

CHAR
VARCHAR

TINYINT
SMALLINT
INTEGER
BIGINT
FLOAT
DOUBLE
BIT
PACKEDDECIMAL1
ZONEDDECIMAL1
BINARY
DATE
TIME
TIMESTAMP

getBigDecimal

BINARY3
PACKEDDECIMAL1
ZONEDDECIMAL1

TINYINT
SMALLINT
INTEGER
BIGINT
FLOAT
DOUBLE
BIT
CHAR
VARCHAR

getClob CLOB2 all others result in an exception
getBytes BINARY

SMALLINT
INTEGER
BIGINT
FLOAT
DOUBLE
BIT
CHAR
VARCHAR
PACKEDDECIMAL1
ZONEDDECIMAL1
DATE
TIME

TIMESTAMP

getDate DATE

CHAR
VARCHAR
TYIMESTAMP

getTime TIME

CHAR
VARCHAR
TIMESTAMP

getTimestamp TIMESTAMP

CHAR
VARCHAR
DATE
TIME

Note:
  1. PACKEDDECIMAL and ZONEDDECIMAL are data type extensions for IMS Universal JDBC driver and the IMS Universal DL/I driver. All other types are standard SQL types defined in SQL92. Restriction: PACKEDDECIMAL and ZONEDDECIMAL data types do not support the Sign Leading or Sign Separate modes. For these two data types, sign information is always stored with the Sign Trailing method.
  2. The CLOB data type is supported only for the retrieval and storage of XML data.
  3. The BINARY data type is valid only for decimal data used with a binary type converter.

If the field type is either PACKEDDECIMAL or ZONEDDECIMAL, the type qualifier is the COBOL PICTURE string that represents the layout of the field. All COBOL PICTURE strings that contain valid combinations of 9s, Ps, Vs, and Ss are supported. Expansion of PICTURE strings is handled automatically. For example, '9(5)' is a valid PICTURE string. For zoned decimal numbers, the decimal point can also be used in the PICTURE string. PIC 9(06)V99 COMP and PIC 9(06)V99 COMP-4 are valid PICTURE clauses for BINARY decimal data.

If the field contains DATE, TIME, or TIMESTAMP data, the type qualifier specifies the format of the data. For example, a type qualifier of ddMMyyyy indicates that the data is formatted as follows:
11122015 is December 11, 2015

For DATE and TIME types, all formatting options in the java.text.SimpleDateFormat class are supported.

For the TIMESTAMP type, the formatting option 'f' is available for nanoseconds. TIMESTAMP can contain up to nine 'f's and replaces the 'S' options for milliseconds. Instead, 'fff' indicates milliseconds of precision. An example TIMESTAMP format is as follows:
yyyy-mm-dd hh:mm:ss.fffffffff