Table 5-2 “Data Type Conversions” shows the supported data type
conversions between ALLBASE/SQL and JDBC. For conversions from JDBC
to Java, please refer to a JDBC book or the Java JDBC documentation.
Those conversions are generic to all JDBC Drivers.
A description of each ALLBASE/SQL and JDBC data type can be
found in Appendix A “Data Types”
Suggested conversions are denoted by a capital letter "X" in
the conversion grid. Conversions which are supported, but which
may result in a loss of precision, overflow, or rounding, are denoted
by a lowercase letter "x" in the conversion grid.
Table 5-2 Data Type Conversions
JDBC DATA TYPES (vertical) | TINYINT | SMALLINT | INTEGER | BIGINT | REAL | FLOAT | DOUBLE | DECIMAL | NUMERIC | BIT | CHAR | VARCHAR | LONGVARCHAR | BINARY | VARBINARY | LONGVARBINARY | DATE | TIME | TIMESTAMP |
ALLBASE/SQL DATA TYPES (horizontal) |
SMALLINT (16-bits) | x | X | X | X | X | X | X | X | X | x | X | X | X | x | x | x | | | |
INTEGER (32-bits) | x | x | X | X | x | x | x | X | X | x | X | X | X | x | x | x | | | |
REAL | x | x | x | x | X | X | X | X | X | X | X | X | X | x | x | x | | | |
FLOAT(1...24) | x | x | x | x | x | x | X | X | X | X | X | X | X | x | x | x | | | |
FLOAT(25...53) | x | x | x | x | x | x | X | X | X | X | x | x | x | x | x | x | | | |
DOUBLE PRECISION | x | x | x | x | x | x | X | X | X | x | X | X | X | x | x | x | | | |
DECIMAL | x | x | x | x | x | x | x | X | X | x | X | X | X | x | x | x | | | |
NUMERIC | x | x | x | x | x | x | x | X | X | x | X | X | X | x | x | x | | | |
CHAR | x | x | x | x | x | x | x | x | x | x | X | X | X | x | x | x | | | |
VARCHAR | x | x | x | x | x | x | x | x | x | x | X | X | X | x | x | x | | | |
DATE | | | | | | | | | | | X | X | X | x | x | x | X | | x |
TIME | | | | | | | | | | | X | X | X | x | x | x | | X | x |
DATETIME | | | | | | | | | | | X | X | X | x | x | x | x | x | X |
INTERVAL | | | | | | | | | | | X | X | X | x | x | x | | | |
The conversion of any ALLBASE/SQL data type to the java.sql.Types.BIT data type is such that only the value of zero,
in either numeric or character format, will be converted to the java.sql.Types.BIT value of 0. All other values will be converted
to the java.sql.Types.BIT value of 1. Thus only the integer value 0, the floating-point
value 0.0, the decimal value 0 (not 0.0), and the character string "0" will
be converted to a bit value of 0. Everything else is converted to
a bit value of 1.
The conversion of an ALLBASE/SQL data type to a JDBC data
type that has a smaller degree of precision (such as conversion
from ALLBASE/SQL INTEGER to java.sql.Types.SMALLINT) will follow the Java VM rules of casting one
data type to another. This may result in different values on different
Java platforms. There is also no warning generated when this occurs.
It is up to the application developer to choose the appropriate
JDBC data type.
The conversion of an ALLBASE/SQL character data type to a
JDBC numeric data type uses the Java numeric conversion routines
and any necessary numeric casting. Thus this could result in a java.lang.NumberFormatException being shown when the conversion is performed.
Again, the application developer should take the necessary precautions.