Related reference
“Properties for the IBM Data Server Driver for JDBC and SQLJ” on page 201
“DB2SimpleDataSource class” on page 352
“DB2XADataSource class” on page 366
Java packages for JDBC support
Before you can invoke JDBC methods, you need to be able to access all or parts of
various Java packages that contain those methods.
You can do that either by importing the packages or specific classes, or by using
the fully-qualified class names. You might need the following packages or classes
for your JDBC program:
java.sql
Contains the core JDBC API.
javax.naming
Contains classes and interfaces for Java Naming and Directory Interface
(JNDI), which is often used for implementing a DataSource.
javax.sql
Contains methods for producing server-side applications using Java
com.ibm.db2.jcc
Contains the implementation of JDBC for the IBM Data Server Driver for
JDBC and SQLJ.
Related concepts
“Example of a simple JDBC application” on page 7
Learning about a data source using DatabaseMetaData methods
The DatabaseMetaData interface contains methods that retrieve information about a
data source. These methods are useful when you write generic applications that
can access various data sources.
In generic applications that can access various data sources, you need to test
whether a data source can handle various database operations before you execute
them. For example, you need to determine whether the driver at a data source is at
the JDBC 3.0 level before you invoke JDBC 3.0 methods against that driver.
DatabaseMetaData methods provide the following types of information:
v Features that the data source supports, such as the ANSI SQL level
v Specific information about the JDBC driver, such as the driver level
v Limits, such as the maximum number of columns that an index can have
v Whether the data source supports data definition statements (CREATE, ALTER,
DROP, GRANT, REVOKE)
v Lists of objects at the data source, such as tables, indexes, or procedures
v Whether the data source supports various JDBC functions, such as batch updates
or scrollable ResultSets
v A list of scalar functions that the driver supports
To invoke DatabaseMetaData methods, you need to perform these basic steps:
1. Create a DatabaseMetaData object by invoking the getMetaData method on the
connection.
2. Invoke DatabaseMetaData methods to get information about the data source.
Chapter 3. JDBC application programming 21