Chapter 7. JDBC and SQLJ reference information
The IBM implementations of JDBC and SQLJ provide a number of application
programming interfaces, properties, and commands for developing JDBC and SQLJ
applications.
Data types that map to database data types in Java applications
To write efficient JDBC and SQLJ programs, you need to use the best mappings
between Java data types and table column data types.
The following tables summarize the mappings of Java data types to JDBC and
database data types for a DB2 Database for Linux, UNIX, and Windows, DB2 for
z/OS, or IBM Informix Dynamic Server (IDS) system.
Data types for updating table columns
The following table summarizes the mappings of Java data types to database data
types for PreparedStatement.setXXX or ResultSet.updateXXX methods in JDBC
programs, and for input host expressions in SQLJ programs. When more than one
Java data type is listed, the first data type is the recommended data type.
Table 25. Mappings of Java data types to database server data types for updating database tables
Java data type Database data type
short SMALLINT
boolean
1
, byte
1
, java.lang.Boolean SMALLINT
int, java.lang.Integer INTEGER
long, java.lang.Long BIGINT
11
float, java.lang.Float REAL
double, java.lang.Double DOUBLE
java.math.BigDecimal DECIMAL(p,s)
2
java.math.BigDecimal DECFLOAT(n)
3,4
java.lang.String CHAR(n)
5
java.lang.String GRAPHIC(m)
6
java.lang.String VARCHAR(n)
7
java.lang.String VARGRAPHIC(m)
8
java.lang.String CLOB
9
java.lang.String XML
10
byte[] CHAR(n) FOR BIT DATA
5
byte[] VARCHAR(n) FOR BIT DATA
7
byte[] BINARY(n)
5, 12
byte[] VARBINARY(n)
7, 12
byte[] BLOB
9
byte[] ROWID
byte[] XML
10
© Copyright IBM Corp. 1998, 2008 193