Data Types
- Last Updated: February 13, 2020
- 2 minute read
- DataDirect Connectors
- JDBC
- MongoDB 6.0
- Documentation
The following table shows how data types supported by the driver map to JDBC data types.
Note: Default mappings can be overridden using the Schema Tool. See "Defining Columns" for
additional information.
| MongoDB Data Type | JDBC Data Type |
|---|---|
| Array1 | LONGVARCHAR (-1) |
| Bigint | BIGINT (-5) |
| Bindata | VARBINARY (-3) |
| Boolean | BOOLEAN (16) |
| Date | TIMESTAMP (93) |
| Decimal1282 | DECIMAL (3) |
| Double | DOUBLE (8) |
| Integer | INTEGER (4) |
| Object3 | LONGVARCHAR (-1) |
| ObjectID4 | VARCHAR (12) |
| String5, 6, 7 | CHAR (1), VARCHAR (12), or LONGVARCHAR (-1) |
1 Complex data types can be returned as strings in the
JSON format, or can be normalized such that nested elements are
returned as columns in a relational table.
2 The
driver reports a precision of 68 digits this type; however, the
native type limits the maximum number of digits before or after the
decimal to 34 digits.
3 Complex
data types can be returned as strings in the JSON format, or can be
normalized such that nested elements are returned as columns in a
new logical table.
4 The
CAST_TO_NATIVE function escape may be needed to select or insert a
value of the ObjectID type when MongoDB has inconsistent native
types for a given field. See "Default Mapping of Columns with
Inconsistent Native Data Types" and "CAST_TO_NATIVE Function Escape"
for details.
5 When
the driver discovers a column with a String size less than or equal
to 4000 characters, String is mapped as VARCHAR and the precision is
4000 characters. When a column with a String size greater than 4000
characters is discovered, String is mapped as LONGVARCHAR and
precision is 16 MB.
6 During the initial
discovery and normalization process, you can use the
DefaultVarcharSize configuration option to specify the default
length of fields that are discovered and mapped as Varchar by the
driver. If the driver discovers a field with String data of a
greater length, the String data is truncated to the length of the
specified value. See "DefaultVarcharSize (Configuration Option" for
details.
7 You can map String to CHAR, VARCHAR,
or LONGVARCHAR, regardless of the column size, using the Schema
Tool. See "Creating and Customizing Schemas Using the DataDirect
Schema Tool" and "Defining Columns" for details.