EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #33 background imageLoading...
Page #33 background image
import java.sql.*; // JDBC base
import javax.sql.*; // Addtional methods for JDBC
import com.ibm.db2.jcc.*; // IBM Data Server Driver for JDBC and SQLJ 1
// interfaces
DB2SimpleDataSource dbds=new DB2SimpleDataSource(); 2
dbds.setDatabaseName("dbloc1"); 3
// Assign the location name
dbds.setDescription("Our Sample Database");
// Description for documentation
dbds.setUser("john");
// Assign the user ID
dbds.setPassword("dbadm");
// Assign the password
Connection con=dbds.getConnection(); 4
// Create a Connection object
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.
Chapter 3. JDBC application programming 17

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability