Administration Getting Started
As a database administrator, you might need to set up an application
to run against the database. There are certain steps you must perform,
depending on the type of application to be run. This section covers the following topics:
- Running DB2 embedded SQL applications
- Running Call Level Interface (CLI) / Open Database Connectivity
(ODBC) applications. Non-ODBC applications, such as VX-REXX, come with their own set-up
instructions
- Running Java programs
In addition, you can use Lotus Approach with DB2. This is described in the Using Lotus Approach with DB2
booklet (provided in the product box with DB2).
To run a database client application that was developed using the DB2 Software Developer's Kit and ensure it can successfully access a DB2 database, follow the
steps below:
- Be sure that DB2 is started on the database server to which the
application program is connecting. If it is not:
- From the Control Center, click mouse button 2 on the icon
representing the DB2 instance you want to start, and select Start
from the pop-up menu. If the instance is local, it is started automatically.
If the instance is remote, the Attach window opens prompting you for a user ID
and password.
- Bind the DB2 utilities and the embedded SQL applications to the database.
If you will also run CLI/ODBC applications, you can bind the
CLI/ODBC driver at this point as well. See the Quick Beginnings book for your server platform.
- Run the application programs.
The DB2 Call Level Interface (CLI) run-time environment and the ODBC driver
are included with the DB2 Client Application Enabler. This is contained
on the DB2 Client Pack CD-ROM or can be downloaded from the Web page at
http://www.software.ibm.com/data/db2.
This support enables applications developed using ODBC and DB2 CLI APIs to
work with any DB2 server. DB2 CLI application development support is
provided by the DB2 Software Developer's Kit (DB2 SDK) which is part of
the separately orderable DB2 Application Development Kit product.
Before DB2 CLI or ODBC applications can access DB2, the DB2 CLI
packages must be bound on the server. Although this will occur
automatically on the first connection if the user has the required authority
to bind the packages, it is recommended that the administrator do this first
with each version of the client on each platform that will access the server.
See the Quick Beginnings manual for specific details.
The following general steps are required on the client system to give DB2
CLI and ODBC applications access to DB2 databases. These instructions assume
that you have successfully connected to DB2 using a valid user ID and
password. Depending on the platform many of these steps are automatic.
- Use the Control Center to add the remote system (if you have separate
client and server machines) so that its instances and databases can be made
known to the Control Center, then add the instances and databases for that
system. (Your local system is represented by the icon labelled
Local.) If you do not have access to this program you can use the
catalog command in the command line processor.
- On all platforms other than OS/2 and Windows 3.1, the DB2 CLI/ODBC
driver is automatically installed when the DB2 Client Application Enabler is
installed, and therefore nothing needs to be done. On OS/2 and Windows
3.1 you must use the Install ODBC Driver icon to install both the
DB2 CLI/ODBC driver and the ODBC driver manager.
- To access the DB2 database from ODBC:
- The Microsoft, Visigenic, or other ODBC Driver Manager must already be
installed (this is done by default during the installation of DB2).
- The DB2 databases must be registered as ODBC data sources. The ODBC driver
manager does not read the DB2 catalog information; instead it references its
own list of data sources.
- If a DB2 table does not have a unique index then many ODBC applications
will open it as read-only. Create a unique index for each DB2 table that is to
be updated by an ODBC application. Refer to the CREATE INDEX
statement in the SQL Reference. Using the Control Center you would alter the settings of the table, then
click on the Primary Key tab and move one or more columns from the
available columns list over to the primary key columns list. Any column you
select as part of the primary key must be defined as NOT NULL.
- Various CLI/ODBC Configuration Keywords can be set to modify the behavior
of DB2 CLI/ODBC and the applications using it.
- If you followed the above steps to install ODBC support, and added DB2
databases as ODBC data sources, your ODBC applications will now be able to
access them.
For specific instructions see the Quick Beginnings manual for your platform.
You can use DB2 Java Database Connectivity (JDBC) support to run the
following types of Java programs:
- Java applications, which rely on the DB2 Client Application Enabler to
connect to DB2.
- Java applets, that do not require any other DB2 component code on the
client.
Java can also be used on the server to write user-defined functions, stored
procedures, and table functions.
For further information on developing Java applications that access DB2
databases refer to the Web page located at
http://www.software.ibm.com/data/db2/java/ and the Road Map to DB2 Programming.
The following environment variables must be set to run Java
programs:
- OS/2, Windows 95 and Windows NT
-
- CLASSPATH includes "." and the file sqllib\java\db2java.zip
- PATH includes the directory sqllib\bin
- LIBPATH includes the directory sqllib\dll (OS/2 only)
- UNIX (AIX, Solaris and HP-UX)
- In the following settings instance_name is the home directory of
the DB2 instance owner.
- CLASSPATH includes "." and the file
instance_name/sqllib/java/db2java.zip
- PATH includes the directory instance_name/sqllib/bin
- LD_LIBRARY_PATH includes the directory instance_name/sqllib/lib
- SHLIB_PATH include the the directory instance_name/sqllib/lib
(HP-UX only)
Start your application from the desktop or command line, like any other
application. The DB2 JDBC driver handles the JDBC API calls from your
application and uses the DB2 Client Application Enabler to communicate the
requests to the server and receive the results.
Because Java applets are delivered over the Web, you treat them a bit
differently than Java applications. You must install DB2 (server or client) on
the same machine as your Web server, then install the Java Development Kit
(JDK) Version 1.1 from Sun Microsystems on the server as well (refer to
http://www.software.ibm.com/data/db2/java for details).
To run your applet, you need only a Java-enabled Web browser on the client
machine. When you load your HTML page, the applet tag downloads the Java
applet to your machine, which then downloads the Java class files, including
the COM.ibm.db2.java.sql and COM.ibm.db2.jdbc.net classes and DB2's JDBC
driver. When your applet calls the JDBC API to connect to DB2, the JDBC driver
establishes separate communications with the DB2 database through the JDBC
applet server residing on the DB2 server.
To run your applets, do the following:
- Start the DB2 JDBC applet server on your Web server by entering:
db2jstrt portno
where portno is the number of the unused TCP/IP port that
you specified in the DB2Applt.java file.
- On your client system, start your Web browser and load the HTML file that
imbeds your applet.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
[ DB2 List of Books |
Search the DB2 Books ]