How To Determine Which Type Of Ibm Data Server Driver For Jdbc And Sqlj Connectivity To Use - IBM DB2 Manual

Table of Contents

Advertisement

import java.sql.*;
import javax.sql.*;
import com.ibm.db2.jcc.*; // IBM Data Server Driver for JDBC and SQLJ
DB2SimpleDataSource dbds=new DB2SimpleDataSource();
dbds.setDatabaseName("dbloc1");
dbds.setDescription("Our Sample Database");
dbds.setUser("john");
dbds.setPassword("dbadm");
Connection con=dbds.getConnection();
Note
Description
1
Import the package that contains the implementation of the DataSource interface.
2
Creates a DB2SimpleDataSource object. DB2SimpleDataSource is one of the IBM Data
Server Driver for JDBC and SQLJ implementations of the DataSource interface. See
"Creating and deploying DataSource objects" for information on DB2's DataSource
implementations.
3
The setDatabaseName, setDescription, setUser, and setPassword methods assign
attributes to the DB2SimpleDataSource object. See "Properties for the IBM Data
Server Driver for JDBC and SQLJ" for information about the attributes that you
can set for a DB2SimpleDataSource object under the IBM Data Server Driver for
JDBC and SQLJ.
4
Establishes a connection to the data source that DB2SimpleDataSource object dbds
represents.
Related concepts
"User ID and password security under the IBM Data Server Driver for JDBC
and SQLJ" on page 448
"User ID-only security under the IBM Data Server Driver for JDBC and SQLJ"
on page 450
"Encrypted password, user ID, or user ID and password security under the
IBM Data Server Driver for JDBC and SQLJ" on page 451
"Kerberos security under the IBM Data Server Driver for JDBC and SQLJ" on
page 453
"IBM Data Server Driver for JDBC and SQLJ trusted context support" on page
456
"IBM Data Server Driver for JDBC and SQLJ support for SSL" on page 458
Related tasks
"Connecting to a data source using SQLJ" on page 103
"Creating and deploying DataSource objects" on page 19
Related reference
"Properties for the IBM Data Server Driver for JDBC and SQLJ" on page 201
"DB2SimpleDataSource class" on page 352
How to determine which type of IBM Data Server Driver for
JDBC and SQLJ connectivity to use
The IBM Data Server Driver for JDBC and SQLJ supports two types of
connectivity: type 2 connectivity and type 4 connectivity.
// JDBC base
// Addtional methods for JDBC
// interfaces
// Assign the location name
// Description for documentation
// Assign the user ID
// Assign the password
// Create a Connection object
Chapter 3. JDBC application programming
1
2
3
4
17

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents