When you retrieve data from a database into an iterator object (see Handling Result Sets) or into a host variable, you must use Java types that are compatible with the SQL types. The following table shows valid conversions from SQL types to Java types.
SQL Type | Java Type |
---|---|
BLOB | byte[] |
BOOLEAN | boolean |
BYTE | byte[] |
CHAR, CHARACTER | String |
CHARACTER VARYING | String |
CLOB | byte[] |
DATE | java.sql.Date |
DATETIME | java.sql.Timestamp |
DECIMAL, NUMERIC, DEC | java.math.BigDecimal |
FLOAT, DOUBLE PRECISION | double |
INT8 | long |
INTEGER, INT | int |
INTERVAL | IfxIntervalDF, IfxIntervalYM1 |
LVARCHAR | String |
MONEY | java.math.BigDecimal |
NCHAR, NVARCHAR | String |
SERIAL | int |
SERIAL8 | long |
SMALLFLOAT | float2 |
SMALLINT | short |
TEXT | String |
VARCHAR | String |
1 IfxIntervalYM and IfxIntervalDF are Informix extensions to JDBC 2.0.2 This mapping is JDBC compliant. You can use IBM Informix JDBC Driver to map SMALLFLOAT data type (via the JDBC FLOAT data type) to the Java double data type for backward compatibility by setting the IFX_GET_SMFLOAT_AS_FLOAT environment variable to 1. |
You must also use compatible Java types for host variables that are arguments to SQL operations. This table shows valid conversions from Java types to SQL types.
Java Type | SQL Type |
---|---|
java.math.BigDecimal | DECIMAL |
boolean | BOOLEAN |
byte[] | BYTE |
java.sql.Date | DATE |
double | FLOAT1 |
float | SMALLFLOAT |
int | INT |
long | INT8 |
short | SMALLINT |
String | CHAR |
java.sql.Time | DATETIME |
java.sql.Timestamp | DATETIME |
com.informix.jdbc.IfxIntervalDF | INTERVAL |
com.informix.jdbc.IfxIntervalYM | INTERVAL |
1 This mapping is JDBC compliant. You can use IBM Informix JDBC Driver to map the Java double data type (via the JDBC FLOAT data type) to the Informix SMALLFLOAT data type for backward compatibility by setting the IFX_GET_SMFLOAT_AS_FLOAT environment variable to 1. |