to DB2 database on a mainframes
The DB2 which runs on the mainframes is
basically a DB2 server; every server has an IP address and a port number which can
be used to access the server.
Note: A single IP address can have multiple ports. Each port will be for a particular
service. For example port 80 will be a web server (for processing web page requests),
while 21 will be for processing FTP requests and another port will be for DB2.
All these services when provided from
a single machine will have the same IP address but the ports will vary.
Which port to connect to?
So the first thing you need to know to
connect to DB2 on mainframes is the IP and port to access.
In mainframes get into the DB2 functions
option (usually D;D); then go into DB2I (DB2 interactive) primary menu and then
option 7 (DB2 commands) -> this is the panel for executing DB2 commands.
In the DB2I defaults option (option D)
give the DB2 name for which you want to get details -> a 4 character name. Then
go to option 7 (DB2 commands). DB2 on mainframes refers to a Database Server Name
as the "location name" (this will be four character name).
Execute the DB2 command:
You will now get the IP address and TCP
port for this particular database. Now we know how to reach our DB2 server on mainframes
List of D2 commands:
DDF – Distributed Data Facility helps DB2 accept connections from outside
the local system.
Connecting to the mainframe
Next step is connecting to this server.
There are 2 ways to connect to the
What is DB2 Connect?
DB2 Connect makes your company's host
data directly available to your personal computer and LAN-based workstations. It
connects desktop and palm-top applications to your company's mainframe and minicomputer
host databases for access to your enterprise information no matter where it is.
DB2 Connect provides the application enablement and robust, highly scalable communication
infrastructure for connecting Web, Windows, UNIX, Linux and mobile applications
to z/OS and AS/400 data. DB2 Connect is included in many of the DB2 products.
What are DB2 Clients?
There are four types of DB2 clients:
Run-Time Client Lite - is a smaller footprint
version of the DB2 Run-Time Client and is available only on Windows
Run-Time Client - provides basic,
non-GUI access to DB2 databases.
Administration client - used to
remotely administer a DB2 server. The DB2 Administration client also contains all
of the functionality available in the DB2 Run-Time client.
Application Development client - Use this
type of DB2 client to develop DB2 database applications, including stored procedures,
user defined functions, and client applications. The DB2 Application Development
client also contains all of the functionality available in the DB2 Run-Time client.
What is the difference DB2 client and
A database cannot be created on a DB2
client; you can only access databases that reside on DB2 servers.
DB2 Client is free client for DB2 Linux,
DB2 Connect is chargeable client (can
be also server) and includes OS/400 and/or z/OS connectivity/license. So, you pay
for only OS/400 or z/OS connectivity.
Where to download this?
Google for “DB2 Connect Download” and
you will get the IBM link from where it can be downloaded; do read the licensing
terms before using it. Once downloaded setup DB2 Connect and also install the .NET
add-ons (present as part of the same setup package).
Once this is done the IBM.Data.DB2 namespace
will be available in Visual Studio .NET while developing applications. You need
to import IBM.Data.DB2 in your .NET application.
There are multiple ways to connect to
a DB2 database from .NET:
IBM.Data.DB2 -> better to use this
Dim con As DB2Connection
con = New DB2Connection("Database=database name;Server=ipaddress:port;Uid=userid;Pwd=password")
is dependent on your mainframe installation. The database name is the location name
(the 4 character name).
Server details is what we got through DISPLAY DDF command.
After you’ve formed the connection string
try opening the connection and closing it.
If the connection is proper then you won’t
get any run time errors.
DB2 Connect also provides a Configuration
Assistant (a GUI) using which you can test whether you are able to connect to the
From the start menu get into IBM DB2 and
you will find Configuration Assistant. Here use the “Add database using wizard”
option to add a database connection and test it.
If using a Gateway
The process for using a gateway is the
same as earlier except that for the server name in the connection string you would
give the IP address of the machine having DB2 Connect. The port would be 50000 (default
port used by DB2 Connect Server).
For the server: The PC which acts as the gateway should have
DB2 Connect Server installed – and here we would establish a connection using Configuration
Assistant to connect to the mainframe’s DB2. The name (alias) created for this connection
is what should be specified in the connection string used by other PCs to connect
to this server. The DB2 server should have been started – go through Administrative
panel to the Services panel and start the DB2 related services.
For the computers which connect to
the server: The computer
which connects to the Connect Server just needs to have the DB2 run time client
installed in it (this is another IBM product but this is a very small product when
compared to DB2 Connect). DB2 Connect is not required on these PCs since the gateway
already has Connect installed. Server name and port should point to the PC with
DB2 Connect and not to the mainframes DB2.
The DOS command:
netstat –a => displays all active TCP/IP
connections as well as ports on which the computer is listening.
Run this command on the PC connecting
to the DB2 Connect Server and you will find it is listening on port 50000.
----- by Jabez and SS
Copyright © 2006 Sethu Subramanian All
rights reserved. Sign my guestbook.
Copyright © 2012 Sethu Subramanian All rights
reserved. Sign my guestbook.
Go here to know what's new