Data types and result conversion
JDBC 4.x selects an engine-specific type system. The following table gives the declared JDBC type and default Java class for DuckDB result columns; typed getters can request conversions supported by the driver.
The following table describes DuckDB result type mappings.
| DuckDB type | java.sql.Types value | Default Java class |
|---|---|---|
BOOLEAN | BOOLEAN | Boolean |
TINYINT | TINYINT | Byte |
UTINYINT / SMALLINT | SMALLINT | Short |
USMALLINT / INTEGER | INTEGER | Integer |
UINTEGER / BIGINT | BIGINT | Long |
UBIGINT / HUGEINT / UHUGEINT / BIGNUM | OTHER | BigInteger |
FLOAT / DOUBLE | FLOAT / DOUBLE | Float / Double |
DECIMAL | DECIMAL | BigDecimal |
VARCHAR / BIT | VARCHAR | String |
BLOB / GEOMETRY | VARBINARY | byte[] |
UUID | OTHER | String |
DATE | DATE | java.sql.Date |
TIME / TIME_NS | TIME | java.sql.Time |
TIME WITH TIME ZONE | TIME_WITH_TIMEZONE | java.sql.Time |
TIMESTAMP / TIMESTAMP_S / TIMESTAMP_MS / TIMESTAMP_NS | TIMESTAMP | java.sql.Timestamp |
TIMESTAMP WITH TIME ZONE | TIMESTAMP_WITH_TIMEZONE | java.sql.Timestamp |
LIST / ARRAY | ARRAY | java.sql.Array |
INTERVAL / JSON / VARIANT / STRUCT / TUPLE / MAP / UNION / ENUM | OTHER | String |
Read extended values
Read large unsigned and 128-bit integers as BigInteger rather than narrowing them to long. The driver declares UBIGINT, HUGEINT, and UHUGEINT as Types.OTHER with a BigInteger Java class.
Use getArray for list and array results. Array.getArray() returns a String[], and the array base type is VARCHAR. Struct, map, union, interval, and variant values have string-valued default mappings.
For geometry results that use the Arrow geoarrow.wkb extension, getBytes returns the stored well-known binary bytes and getString renders well-known text. On string-result paths, getBytes converts geometry well-known text to well-known binary and decodes DuckDB BLOB text to bytes.
ResultSetMetaData.getColumnType() reports the JDBC type selected by the driver, and getColumnClassName() reports its declared Java class.