Jdbc Connection Objects; Creating And Deploying Datasource Objects - IBM DB2 Manual

Table of Contents

Advertisement

JDBC connection objects

When you connect to a data source by either connection method, you create a
Connection object, which represents the connection to the data source.
You use this Connection object to do the following things:
v Create Statement, PreparedStatement, and CallableStatement objects for
executing SQL statements. These are discussed in "Executing SQL statements in
JDBC applications".
v Gather information about the data source to which you are connected. This
process is discussed in "Learning about a data source using DatabaseMetaData
methods".
v Commit or roll back transactions. You can commit transactions manually or
automatically. These operations are discussed in "Commit or roll back a JDBC
transaction".
v Close the connection to the data source. This operation is discussed in
"Disconnecting from data sources in JDBC applications".
Related concepts
"JDBC interfaces for executing SQL" on page 24
Related tasks
"Disconnecting from data sources in JDBC applications" on page 99
"Committing or rolling back JDBC transactions" on page 74
"Learning about a data source using DatabaseMetaData methods" on page 21
"Setting the isolation level for an SQLJ transaction" on page 153
Related reference
" IBM Data Server Driver for JDBC and SQLJ isolation levels" on page 73

Creating and deploying DataSource objects

JDBC versions starting with version 2.0 provide the DataSource interface for
connecting to a data source. Using the DataSource interface is the preferred way to
connect to a data source.
Using the DataSource interface involves two parts:
v Creating and deploying DataSource objects. This is usually done by a system
administrator, using a tool such as WebSphere Application Server.
v Using the DataSource objects to create a connection. This is done in the
application program.
This topic contains information that you need if you create and deploy the
DataSource objects yourself.
The IBM Data Server Driver for JDBC and SQLJ provides the following DataSource
implementations:
v com.ibm.db2.jcc.DB2SimpleDataSource, which does not support connection
pooling. You can use this implementation with IBM Data Server Driver for JDBC
and SQLJ type 2 connectivity or IBM Data Server Driver for JDBC and SQLJ
type 4 connectivity.
v com.ibm.db2.jcc.DB2ConnectionPoolDataSource, which supports connection
pooling. You can use this implementation with IBM Data Server Driver for JDBC
and SQLJ type 2 connectivity or IBM Data Server Driver for JDBC and SQLJ
type 4 connectivity.
Chapter 3. JDBC application programming
19

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents