Datatype - Conversion between Java, Oracle, SQL Server and DB2

1 - About

Datatype conversions between Java, Oracle, Microsoft SQL Server and DB2.

Java Oracle Microsoft SQL Server DB2
java.lang.String varchar2(255) nvarchar(50) varchar(255)
int number(20,0)
long number(20,0) int integer
float number(20,5) float float
double number(30,0) float double
byte number(10,0) smallint smallint
char char(1) char char
short number(10,0) int integer
boolean number(1,0) bit bit
java.util.Date date
java.io.Serializable blob varbinary varchar for bit data

This conversions have been found here:

owb_home\j2ee\home\config\database-schemas

and you have also:

  • informix,
  • hypersonic,
  • ms-access,
  • postgresql,
  • and sybase
Kafka Schema Type MySQL Oracle PostgreSQL SQLite SQL Server
INT8 TINYINT NUMBER(3,0) SMALLINT NUMERIC TINYINT
INT16 SMALLINT NUMBER(5,0) SMALLINT NUMERIC SMALLINT
INT32 INT NUMBER(10,0) INT NUMERIC INT
INT64 BIGINT NUMBER(19,0) BIGINT NUMERIC BIGINT
FLOAT32 FLOAT BINARY_FLOAT REAL REAL REAL
FLOAT64 DOUBLE BINARY_DOUBLE DOUBLE PRECISION REAL FLOAT
BOOLEAN TINYINT NUMBER(1,0) BOOLEAN NUMERIC BIT
STRING VARCHAR(256) NCLOB TEXT TEXT VARCHAR(MAX)
BYTES VARBINARY(1024) BLOB BYTEA BLOB VARBINARY(MAX)
‘Decimal’ DECIMAL(65,s) NUMBER(*,s) DECIMAL NUMERIC DECIMAL(38,s)
‘Date’ DATE DATE DATE NUMERIC DATE
‘Time’ TIME(3) DATE TIME NUMERIC TIME
‘Timestamp’ TIMESTAMP(3) TIMESTAMP TIMESTAMP NUMERIC DATETIME2

3 - Documentation / Reference

code/type/conversion.txt · Last modified: 2017/10/18 17:19 by gerardnico