Home | Previous Page | Next Page   Appendix C. Mapping Data Types >

Data Type Mapping for ResultSet.getXXX() Methods

Use the ResultSet.getXXX() methods to transfer data from an Informix database to a Java program that uses the JDBC API to connect to an Informix database. For example, use the ResultSet.getString() method to get the data stored in a column of data type LVARCHAR.

Important:
If you use an expression within an SQL statement—for example, SELECT mytype::LVARCHAR FROM mytab—you might not be able to use ResultSet.getXXX(columnName) to retrieve the value. Use ResultSet.getXXX(columnIndex) to retrieve the value instead.

The following table lists the ResultSet.getXXX() methods that IBM Informix JDBC Driver supports for nonextended data types. The top heading lists the standard JDBC API data types defined in the java.sql.Types class. These translate to specific Informix data types, as shown in the first table in Data Type Mapping Between Informix and JDBC Data Types. The table lists the getXXX() methods you can use to retrieve data of a particular JDBC API data type.

An uppercase and bold X indicates the recommended getXXX() method to use; a lowercase x indicates other getXXX() methods supported by IBM Informix JDBC Driver.

getXXX() Method JDBC API Data Types from java.sql.Types
TINYINT SMALLINT INTEGER BIGINT REAL FLOAT DOUBLE DECIMAL NUMERIC BIT CHAR VARCHAR LONGVARCHAR BINARY VARBINARY LONGVARBINARY DATE TIME TIMESTAMP
getByte() X x x x x x x x x x1 x1
getShort() x X x x x x x x x x1 x1
getInt() x x X x x x x x x x1 x1
getLong() x x x X x x x x x x1 x1
getFloat() x x x x X x x x x x1 x1
getDouble() x x x x x X X x x x1 x1
getBigDecimal() x x x x x x x X X x x
getBoolean() x x x x x x x x x x x
getString() x x x x x x x x x X X x x x x x x x
getBytes() x X X x
getDate() x x X x
getTime() x x X x
getTimestamp() x x x X
getAsciiStream() X x x x
getCharacterStream() X x x x
getUnicodeStream()
getBinaryStream() x x x X
getObject() x x x x x x x x x x x x2 x x x2 x x3 x
Notes:1 The column value must match the type of getXXX() exactly, or an SQLException is raised. If the column value is not within the allowed value range, the getXXX() method raises an exception instead of converting the data type. For example, getByte(1) raises an SQLException if the column value is 1000.2 A byte array is returned.3 A Timestamp object is returned instead of a Time object.

The getXXX() methods return a null value if the retrieved column value is an SQL null value.

The following table lists the ResultSet.getXXX() methods that IBM Informix JDBC Driver supports for the Informix extended data types, the mappings for which are shown in the table on page ***. The table lists the getXXX() methods you can use to retrieve data of a particular extended data type.

An uppercase and bold X indicates the recommended getXXX() method to use; a lowercase x indicates other getXXX() methods supported by IBM Informix JDBC Driver. The table does not include getXXX() methods that you cannot use with any of the Informix extended data types.

getXXX() Method Informix Extended Data Types
BOOLEAN LVARCHAR Opaque types BLOB CLOB BYTE TEXT NAMED ROW UNNAMED ROW SET or MULTISET LIST
getByte() x x
getShort() x
getInt() x
getBoolean() X
getString() X x x
getBytes() x x
getAsciiStream() x x X
getCharacterStream() x x X
getBinaryStream() x x X
getObject() x x X x x x x X X x x
getArray() x x
getBlob() X
getClob() X

The getXXX() methods return a null value if the retrieved column value is an SQL null value.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]