DB2 Version 10.1 for Linux, UNIX, and Windows

Supported SQL data types in DB2GENERAL routines

When you call PARAMETER STYLE DB2GENERAL routines, DB2® converts SQL types to and from Java™ types for you.

Several of these classes are provided in the Java package COM.ibm.db2.app.

Table 1. DB2 SQL Types and Java Objects
SQL Column Type Java Data Type
SMALLINT short
INTEGER int
BIGINT long
REAL1 float
DOUBLE double
DECIMAL(p,s) java.math.BigDecimal
NUMERIC(p,s) java.math.BigDecimal
CHAR(n) java.lang.String
CHAR(n) FOR BIT DATA COM.ibm.db2.app.Blob
VARCHAR(n) java.lang.String
VARCHAR(n) FOR BIT DATA COM.ibm.db2.app.Blob
LONG VARCHAR java.lang.String
LONG VARCHAR FOR BIT DATA COM.ibm.db2.app.Blob
GRAPHIC(n) java.lang.String
VARGRAPHIC(n) String
LONG VARGRAPHIC2 String
BLOB(n)2 COM.ibm.db2.app.Blob
CLOB(n)2 COM.ibm.db2.app.Clob
DBCLOB(n)2 COM.ibm.db2.app.Clob
DATE3 String
TIME3 String
TIMESTAMP3 String
Note:
  1. The difference between REAL and DOUBLE in the SQLDA is the length value (4 or 8).
  2. The Blob and Clob classes are provided in the COM.ibm.db2.app package. Their interfaces include routines to generate an InputStream and OutputStream for reading from and writing to a Blob, and a Reader and Writer for a Clob.
  3. SQL DATE, TIME, and TIMESTAMP values use the ISO string encoding in Java, as they do for UDFs coded in C.

Instances of classes COM.ibm.db2.app.Blob and COM.ibm.db2.app.Clob represent the LOB data types (BLOB, CLOB, and DBCLOB). These classes provide a limited interface to read LOBs passed as inputs, and write LOBs returned as outputs. Reading and writing of LOBs occur through standard Java I/O stream objects. For the Blob class, the routines getInputStream() and getOutputStream() return an InputStream or OutputStream object through which the BLOB content can be processed bytes-at-a-time. For a Clob, the routines getReader() and getWriter() will return a Reader or Writer object through which the CLOB or DBCLOB content can be processed characters-at-a-time.

If such an object is returned as an output using the set() method, code page conversions might be applied in order to represent the Java Unicode characters in the database code page.