JDBC Data Type Conversions

When data is read from a database type to an internal data type, or when data is written from an internal data type to a database type, a set of predefined conversions is used. The following table shows how data is converted between a database type and an internal data type.

Internal Data Type

SQL Data Type

JDBC get Method

JDBC set Method

boolean

BIT

getBoolean

setBoolean

integer

INTEGER

getInt

setInt

long

BIGINT

getBigDecimal

setBigDecimal

date

TIMESTAMP

getTimestamp

setTimestamp

day

DATE

getDate

setDate

float

DECIMAL

getBigDecimal

setBigDecimal

string

VARCHAR

getString

setString

To read data from a database or write data to a database, the JDBC get or set method is used. For example, to read/write a date internal data type from/to a database, the JDBC functions getTimestamp()/setTimestamp() are used. These conversions are used by all JDBC-related steps (such as Jdbc Reader, Jdbc Writer, SQL Execute, and SQL Select).

JDBC Internal Conversions

The JDBC specifications define the JDBC capability for inner type conversions (the difference between which JDBC method you use to read/write data and the real database column data type). These specifications are available here. The conversion abilities of certain drivers depend on the JDBC specification version they implement. Base conversions are defined in API 1.0 and extended in 3.0.

Most of the drivers support JDBC 3.0. However, some drivers may not implement these conversions fully, or a database may use its own extra data types. Real conversion abilities are JDBC driver dependent. The previously mentioned JDBC methods used to read/write data from/to a database were chosen taking into consideration maximum compatibility with major databases and their JDBC connectors.


iWay Software