Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Developer's Guide

- Previous: Container-Managed Persistence Mapping
- Next: Generation Options

## Supported Data Types

CMP supports a set of JDBC data types that are used in mapping Java data fields to SQL types. Supported JDBC data types are as follows: BIGINT, BIT, BLOB, CHAR, CLOB, DATE, DECIMAL, DOUBLE, FLOAT, INTEGER, NUMERIC, REAL, SMALLINT, TIME, TIMESTAMP, TINYINT, VARCHAR.

The following table contains the mappings of Java types to JDBC types when automatic mapping is used.

Table 7–1 Java Type to JDBC Type Mappings

Java Type | JDBC Type | Nullability
--- | --- | ---
`boolean` | `BIT` | No
`java.lang.Boolean` | `BIT` | Yes
`byte` | `TINYINT` | No
`java.lang.Byte` | `TINYINT` | Yes
`double` | `DOUBLE` | No
`java.lang.Double` | `DOUBLE` | Yes
`float` | `REAL` | No
`java.lang.Float` | `REAL` | Yes
`int` | `INTEGER` | No
`java.lang.Integer` | `INTEGER` | Yes
`long` | `BIGINT` | No
`java.lang.Long` | `BIGINT` | Yes
`short` | `SMALLINT` | No
`java.lang.Short` | `SMALLINT` | Yes
`java.math.BigDecimal` | `DECIMAL` | Yes
`java.math.BigInteger` | `DECIMAL` | Yes
`char` | `CHAR` | No
`java.lang.Character` | `CHAR` | Yes
`java.lang.String` | `VARCHAR` or `CLOB` | Yes
`Serializable` | `BLOB` | Yes
`byte[]` | `BLOB` | Yes
`java.util.Date` | `DATE` (Oracle only) `TIMESTAMP` (all other databases) | Yes
`java.sql.Date` | `DATE` | Yes
`java.sql.Time` | `TIME` | Yes
`java.sql.Timestamp` | `TIMESTAMP` | Yes

Note –

Java types assigned to CMP fields must be restricted to Java primitive types, Java `Serializable` types, `java.util.Date`, `java.sql.Date`, `java.sql.Time`, or `java.sql.Timestamp`. An entity bean local interface type (or a collection of such) can be the type of a CMR field.

The following table contains the mappings of JDBC types to database vendor-specific types when automatic mapping is used. For a list of the JDBC drivers currently supported by the Application Server, see the Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Release Notes. For configurations of supported and other drivers, see Configurations for Specific JDBC Drivers.

Table 7–2 Mappings of JDBC Types to Database Vendor Specific Types

JDBC Type | PointBase | Oracle | DB2 | Sybase ASE 12.5 | MS-SQL Server
--- | --- | --- | --- | --- | ---
`BIT` | `BOOLEAN` | `SMALLINT` | `SMALLINT` | `TINYINT` | `BIT`
`TINYINT` | `SMALLINT` | `SMALLINT` | `SMALLINT` | `TINYINT` | `TINYINT`
`SMALLINT` | `SMALLINT` | `SMALLINT` | `SMALLINT` | `SMALLINT` | `SMALLINT`
`INTEGER` | `INTEGER` | `INTEGER` | `INTEGER` | `INTEGER` | `INTEGER`
`BIGINT` | `BIGINT` | `NUMBER` | `BIGINT` | `NUMERIC` | `NUMERIC`
`REAL` | `FLOAT` | `REAL` | `FLOAT` | `FLOAT` | `REAL`
`DOUBLE` | `DOUBLE PRECISION` | `DOUBLE PRECISION` | `DOUBLE` | `DOUBLE PRECISION` | `FLOAT`
`DECIMAL(p,s)` | `DECIMAL(p,s)` | `NUMBER(p,s)` | `DECIMAL(p,s)` | `DECIMAL(p,s)` | `DECIMAL(p,s)`
`VARCHAR` | `VARCHAR` | `VARCHAR2` | `VARCHAR` | `VARCHAR` | `VARCHAR`
`DATE` | `DATE` | `DATE` | `DATE` | `DATETIME` | `DATETIME`
`TIME` | `TIME` | `DATE` | `TIME` | `DATETIME` | `DATETIME`
`TIMESTAMP` | `TIMESTAMP` | `TIMESTAMP(9)` | `TIMESTAMP` | `DATETIME` | `DATETIME`
`BLOB` | `BLOB` | `BLOB` | `BLOB` | `IMAGE` | `IMAGE`
`CLOB` | `CLOB` | `CLOB` | `CLOB` | `TEXT` | `NTEXT`

- Previous: Container-Managed Persistence Mapping
- Next: Generation Options

- © 2010, Oracle Corporation and/or its affiliates