Specifically:
BIGINT
DOUBLE
FLOAT
INTEGER
NUMERIC (what is this?)
REAL
SMALLINT
TINYINT
If I was to guess, I would map them to the Java types as follows, but I am
not sure if this is correct:
BIGINT - long?
DOUBLE - double?
FLOAT - float?
INTEGER - int?
NUMERIC (what is this?) - no idea
REAL - no idea (float or double?)
SMALLINT - short?
TINYINT - byte?
Specifically, I am creating part of a user interface that will look at the
type of a field as defined in JDBC and will also look at the value entered
by the user to determine if the user has exceeded the bounds that can be
stored in this value. It is important that this be done in the user
interface code and not in the data access code.
Regards,
Luther
I do not know if this helps, I know the conversions between the
AS400-Objects and the Java Objects.
It is in the Redbook "Accessing the AS/400 System with JAVA" (SG24-2152-00).
I only have that in printed form, I´ll just type it:
As/400 DB2 Java Object
+++++++++ +++++++++
signed 2byte Number Integer
signed 4byte Number Integer
unsigned 2byte Num Integer
unsigned 4byte Num Integer
signed 4byte float Float
signed 8byte float Float
Packed Decimal BigDecimal
Zoned Decimal Big Decimal
Text String
Regards,
--
Bertolt Meyer
pdv Unternehmensberatung GmbH
Software Department
Osterbekstr. 90b
22083 Hamburg
GERMANY
phon. +49-(0)40-27071-248
fax. +49-(0)40-27071-299
email: in...@pdv-microware.de
WWW: http://www.pdv-online.de
http://java.sun.com:80/products/jdbc/jdbcsw2.html#2.0 Specification
From the JDBC spec (version 1.2):
8 Mapping SQL data types into Java
8.1 Constraints
We need to provide reasonable Java mappings for the common SQL data
types. We also need
to make sure that we have enough type information so that we can correctly
store and retrieve
parameters and recover results from SQL statements.
However, there is no particular reason that the Java data type needs
to be exactly isomorphic
to the SQL data type. For example, since Java has no fixed length arrays,
we can represent both
fixed length and variable length SQL arrays as variable length Java
arrays. We also felt free to
use Java Strings even though they don’t precisely match any of the
SQL CHAR types.
Table 2 shows the default Java mapping for various common SQL data
types. Not all of these
types will necessarily be supported by all databases. The various mappings
are described more
fully in the following sections.
SQL type - Java Type
CHAR - String
VARCHAR - String
LONGVARCHAR - String
NUMERIC - java.math.BigDecimal
DECIMAL - java.math.BigDecimal
BIT - boolean
TINYINT - byte
SMALLINT - short
INTEGER - int
BIGINT - long
REAL - float
FLOAT - double
DOUBLE - double
BINARY - byte[]
VARBINARY - byte[]
LONGVARBINARY - byte[]
DATE - java.sql.Date
TIME - java.sql.Time
TIMESTAMP - java.sql.Timestamp
Table 2: Standard mapping from SQL types to Java types.