Java to DB2 data types Mapping

A

Andres G.

Hi,

I'm working in something related to DB to Java data types mapping and
I'm not sure which java types should I use for the following DB2 types:

DECIMAL -> Should I use Double?
DOUBLE -> Should I use Double?
GRAPHIC -> ?????
LONG VARGRAPHIC -> ?????
REAL -> Should I use Double?
TIME -> java.sql.Time -> java.util.?????
TIMESTAMP -> ?????
VARGRAPHIC -> ?????

Thanks in advance.
 
T

Tim Slattery

Andres G. said:
Hi,

I'm working in something related to DB to Java data types mapping and
I'm not sure which java types should I use for the following DB2 types:
DECIMAL -> Should I use Double?
DOUBLE -> Should I use Double?
REAL -> Should I use Double?

For these it depends on how much precision you need as opposed to how
much size. If you need many digits of precision you might need Java's
BigDecimal. If you need only a few digits precision but you need to
represent extremely large (10**30) or extremely small (10**-30), maybe
double would be a better fit.
GRAPHIC -> ?????
LONG VARGRAPHIC -> ?????
VARGRAPHIC -> ?????

Don't know what these are, but I doubt that Java has anything that
really corresponds. Check the Blob interface, you might find something
there that would help.
TIME -> java.sql.Time -> java.util.?????
TIMESTAMP -> ?????

I expect the Java Time object would work here.

--
Tim Slattery
(e-mail address removed)
 
L

Lee Fesperman

Andres said:
I'm working in something related to DB to Java data types mapping and
I'm not sure which java types should I use for the following DB2 types:

DECIMAL -> Should I use Double?
DOUBLE -> Should I use Double?
GRAPHIC -> ?????
LONG VARGRAPHIC -> ?????
REAL -> Should I use Double?
TIME -> java.sql.Time -> java.util.?????
TIMESTAMP -> ?????
VARGRAPHIC -> ?????

The standard (JDBC) mapping would be:

DECIMAL -> java.math.BigDecimal
DOUBLE -> Double
REAL -> Float
TIME -> java.sql.Time
TIMESTAMP -> java.sql.Timestamp
GRAPHIC, LONG VARGRAPHIC, VARGRAPHIC -> likely byte[]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,270
Messages
2,571,102
Members
48,773
Latest member
Kaybee

Latest Threads

Top