Datatype mapping between Java and SQL

Adaptive Server maps SQL datatypes to Java types (SQL-Java datatype mapping) and Java scalar types to SQL datatypes (Java-SQL datatype mapping). Table 12-3 shows SQL-Java datatype mapping.

Table 12-3: Mapping SQL datatypes to Java types

SQL type

Java type

char

String

varchar

String

nchar

String

nvarchar

String

text

String

numeric

java.math.BigDecimal

decimal

java.math.BigDecimal

money

java.math.BigDecimal

smallmoney

Java.math.BigDecimal

bit

boolean

tinyint

byte

smallint

short

integer

int

real

float

float

double

double precision

double

binary

byte[ ]

varbinary

byte[ ]

image

byte[ ]

datetime

java.sql.Timestamp

smalldatetime

java.sql.Timestamp

Table 12-4 shows Java-SQL datatype mapping.

Table 12-4: Mapping Java scalar types to SQL datatypes

Java scalar type

SQL type

boolean

bit

byte

tinyint

short

smallint

int

integer

long

integer

float

real

double

double