Chapter 7. Jdbc And Sqlj Reference Information; Data Types That Map To Database Data Types In Java Applications - IBM DB2 Manual

Table of Contents

Advertisement

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
short
1
1
boolean
, byte
, java.lang.Boolean
int, java.lang.Integer
long, java.lang.Long
float, java.lang.Float
double, java.lang.Double
java.math.BigDecimal
java.math.BigDecimal
java.lang.String
java.lang.String
java.lang.String
java.lang.String
java.lang.String
java.lang.String
byte[]
byte[]
byte[]
byte[]
byte[]
byte[]
byte[]
© Copyright IBM Corp. 1998, 2008
Database data type
SMALLINT
SMALLINT
INTEGER
11
BIGINT
REAL
DOUBLE
2
DECIMAL(p,s)
3,4
DECFLOAT(n)
5
CHAR(n)
6
GRAPHIC(m)
7
VARCHAR(n)
8
VARGRAPHIC(m)
9
CLOB
10
XML
5
CHAR(n) FOR BIT DATA
VARCHAR(n) FOR BIT DATA
5, 12
BINARY(n)
7, 12
VARBINARY(n)
9
BLOB
ROWID
10
XML
7
193

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents