JdbcDataTypes
From Eigenpedia
Contents |
Supported Data Types
The Farrago JDBC driver supports the following JDBC types:
| JDBC Type | Farrago SQL Type | Java Type | Comments |
| CHAR(p) | CHAR(p) | String | 0 ≤ p ≤ 65535. For column definitions, p > 0. Character Set is not supported |
| VARCHAR(p) | VARCHAR(p) | String | 0 ≤ p ≤ 65535. For column definitions, p > 0. Character Set is not supported |
| BINARY(p) | BINARY(p) | byte[] | 0 ≤ p ≤ 65535 |
| VARBINARY(p) | VARBINARY(p) | byte[] | 0 ≤ p ≤ 65535 |
| NUMERIC(p, s) | NUMERIC(p, s) | java.math.BigDecimal | 0 ≤ p ≤ 19, 0 ≤ s ≤ 19. For 19 digits of precision, range is -9223372036854775808 to 9223372036854775807. |
| DECIMAL(p, s) | DECIMAL(p, s) | java.math.BigDecimal | 0 ≤ p ≤ 19, 0 ≤ s ≤ 19. For 19 digits of precision, range is -9223372036854775808 to 9223372036854775807. |
| BIGINT | BIGINT | long, Long | 64 bit signed integer. Range is -9223372036854775808 to 9223372036854775807. |
| INTEGER | INTEGER | int, Integer | 32 bit signed integer. Range is -2147483648 to 2147483647. |
| SMALLINT | SMALLINT | short, Short | 16 bit signed integer. Range is -32768 to 32767. |
| TINYINT | TINYINT | byte, Byte | 8 bit signed integer. Range is -128 to 127. |
| REAL | REAL | float, Float | 32 bit approx value |
| FLOAT | FLOAT | double, Double | 64 bit approx value |
| DOUBLE | DOUBLE | double, Double | 64 bit approx value |
| BOOLEAN | BOOLEAN | boolean, Boolean | Values are FALSE, TRUE. |
| DATE | DATE | java.sql.Date | Range is 0000-01-01 to 9999-12-31. |
| TIME | TIME | java.sql.Time | Range is 00:00:00.000 to 23:59:59.999. Timezone, precision (max 3) are not fully supported. |
| TIMESTAMP | TIMESTAMP | java.sql.Timestamp | Range is 0000-01-01 00:00:00.000 to 9999-12-31 23:59:59.999. Timezone, precision (max 3) are not fully supported. |
Type Conversion
Type conversion follows the JDBC standard. When converting from an approximate numeric type to an exact numeric type, rounding away from zero is used.
Conversion by getter Methods
The following table gives the data conversions supported by the ResultSet.getXXX methods. An "x" means that the method can retrieve the JDBC type. An "X" means that the method is recommended for retrieving the JDBC type. Unsupported data types and conversions are grayed out.
Conversion by setter methods
The following table gives the data conversions supported by the PreparedStatement.setXXX methods. An "x" means that the method can be used to set the JDBC type. An "X" means that the method is recommended for setting the JDBC type. Unsupported data types and conversions are grayed out.
Validation
When performing data conversion, the Farrago JDBC driver will throw a SQLException for the following cases:
- Invalid type - the column cannot be set or retrieved using the given setXXX or getXXX method because type conversion is not supported between the data type of the column and the java object type.
- Invalid format - the column cannot be set or retrieved using the given setString or getXXX (on a character column) method because the format of the string is invalid
- Value is too long - the binary or character column cannot be set because the byte[] or String is too long.
- Out of range - a numeric value is too large to fit into the target data type
- Not nullable - setNull cannot be used on a non-null column


