Home
 

DB 2

The DdlUtils support for IBM DB2 is based upon version 7. The datatypes and SQL elements in DB2 are described in the DB2 SQL Reference V7. Some specifics related to the JDBC driver and suggested typemappings can also be found here.

DdlUtils provides two platforms for DB2, one for version 7 and one for version 8 and above, which mainly differ in the maximum identifier lengths (see below for details.) Note that you have to specify the v8 platform manually as the auto detection currently always selects the v7 platform.

 

Platform identifiers:

  • DB2 for the v7 platform
  • DB2v8 for the v8 platform

 

Recognized JDBC drivers:

  • com.ibm.db2.jcc.DB2Driver
  • COM.ibm.db2.jdbc.app.DB2Driver
  • COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver
  • com.ibm.as400.access.AS400JDBCDriver

 

Recognized JDBC sub protocols:

  • jdbc:db2
  • jdbc:db2os390
  • jdbc:2os390sqlj
  • jdbc:as400

 

The database supports SQL comments yes
The database supports delimited identifiers yes
The database's maximum identifier length 18 for the v7 platform
The v8 platform supports 128 characters for identifiers (e.g. table names), 30 characters for column names, and 18 for constraints and foreign keys
The database supports default values for LONG types yes
DdlUtils uses sequences for identity columns no
The database supports non-primary key columns as identity columns yes
The database allows INSERT/UPDATE statements to set values for identity columns yes
DdlUtils can read back the auto-generated value of an identity column yes
The database supports non-unique indices yes
DdlUtils can create a database via JDBC no
DdlUtils can drop a database via JDBC no

 

JDBC Type Database Type Additional comments
ARRAY BLOB Will be read back as BLOB
BIGINT BIGINT
BINARY CHAR(n) FOR BIT DATA
BIT SMALLINT DB2 has no native boolean type
Will be read back as SMALLINT
BLOB BLOB
BOOLEAN SMALLINT DB2 has no native boolean type
Will be read back as SMALLINT
CHAR CHAR
CLOB CLOB
DATALINK DATALINK
DATE DATE
DECIMAL DECIMAL
DISTINCT DISTINCT
DOUBLE DOUBLE
FLOAT DOUBLE
INTEGER INTEGER
JAVA_OBJECT BLOB Will be read back as BLOB
LONGVARBINARY LONG VARCHAR FOR BIT DATA
LONGVARCHAR LONG VARCHAR
NULL LONG VARCHAR FOR BIT DATA Will be read back as LONGVARBINARY
NUMERIC DECIMAL Will be read back as DECIMAL
OTHER BLOB Will be read back as BLOB
REAL REAL
REF REF
SMALLINT SMALLINT
STRUCT BLOB Will be read back as BLOB
TIME TIME
TIMESTAMP TIMESTAMP
TINYINT SMALLINT Will be read back as SMALLINT
VARBINARY VARCHAR(n) FOR BIT DATA
VARCHAR VARCHAR