Db2 Udb Ebusiness Guide Ibm Redbooks instant download
Db2 Udb Ebusiness Guide Ibm Redbooks instant download
https://ebookbell.com/product/db2-udb-ebusiness-guide-ibm-
redbooks-51388454
https://ebookbell.com/product/db2-udbs-highfunction-business-
intelligence-in-ebusiness-ibm-redbooks-51388450
https://ebookbell.com/product/db2-udb-exploitation-of-the-windows-
environment-ibm-redbooks-51841914
https://ebookbell.com/product/db2-udb-v8-and-websphere-v5-performance-
tuning-and-operations-guide-ibm-redbooks-974300
https://ebookbell.com/product/sap-solutions-on-ibm-
db2-udb-v822-handbook-wheijen-chen-2166954
Oracle To Db2 Udb Conversion Guide Ibm Redbooks Wheijen Chen
https://ebookbell.com/product/oracle-to-db2-udb-conversion-guide-ibm-
redbooks-wheijen-chen-974302
https://ebookbell.com/product/db2-sql-pl-deployment-and-advanced-
configuration-essential-guide-for-db2-udb-on-linux-unix-windows-i5os-
zos-second-edition-zamil-janmohamed-977794
Advanced Dba Certification Guide And Reference For Db2 Udb V8 For
Linux Unix And Windows Dwaine R Snow
https://ebookbell.com/product/advanced-dba-certification-guide-and-
reference-for-db2-udb-v8-for-linux-unix-and-windows-dwaine-r-
snow-930792
https://ebookbell.com/product/db2-table-editor-tool-version-42-ibm-
redbooks-51388442
https://ebookbell.com/product/db2-web-query-tool-version-12-ibm-
redbooks-51388448
Front cover
Problem determination in
DB2 and WebSphere
Rodolphe Michel
Lijun Gu
Tarun Bhatnagar
Richard Hewitt
JeongKwon Lee
Quentin Presley
ibm.com/redbooks
International Technical Support Organization
July 2002
SG24-6539-00
Take Note! Before using this information and the product it supports, be sure to read the
general information in “Notices” on page xvii.
This edition applies to DB2 Universal Database (UDB) Extended Edition (EE) Version 7 and
WebSphere Advanced Edition Version 4.0.
When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the
information in any way it believes appropriate without incurring any obligation to you.
Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
The team that wrote this redbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Comments welcome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Chapter 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Contents iii
3.1 DB2 UDB Universal Developer’s Edition V7.2 (UDE) . . . . . . . . . . . . . . . . 32
3.1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.2 WebSphere Application Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.2.2 WebSphere Application Server Enterprise Edition V4.0 . . . . . . . . . . 35
3.2.3 WebSphere Application Server Advanced Edition V4.0 . . . . . . . . . . 38
3.2.4 WebSphere Application Server Standard Edition V3.5 . . . . . . . . . . . 41
3.3 The evolution of WebSphere tooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.3.1 Relationship between Site Developer and WebSphere Studio . . . . . 44
3.3.2 Relation between Application Developer and VisualAge for Java . . 44
3.4 WebSphere Studio Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.4.2 WebSphere Studio Site Developer . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.4.3 WebSphere Studio Application Developer . . . . . . . . . . . . . . . . . . . . 46
3.5 VisualAge for Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.5.2 Professional Edition V4.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.5.3 Enterprise Edition V4.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.6 DB2 Stored Procedure Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.6.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.6.2 Installing and configuring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.6.3 Concepts and terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.6.4 Choosing a language for your stored procedures . . . . . . . . . . . . . . . 55
3.6.5 Creating stored procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.6.6 Example stored procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Contents v
7.2 WebSphere installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
7.2.1 Creating an Admin ID on Windows platforms . . . . . . . . . . . . . . . . . 173
7.2.2 Install IBM HTTP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
7.2.3 Install database server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
7.2.4 Post-configuration for WebSphere . . . . . . . . . . . . . . . . . . . . . . . . . 186
7.2.5 Install WebSphere Application Server. . . . . . . . . . . . . . . . . . . . . . . 188
7.2.6 Uninstall WebSphere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
7.3 Configuring WebSphere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
7.3.1 The administration model in WebSphere . . . . . . . . . . . . . . . . . . . . 196
7.3.2 Configuring WebSphere to host applications . . . . . . . . . . . . . . . . . 197
Chapter 10. Case study: IBM Video Central for e-business . . . . . . . . . . 359
10.1 Case study - business rationale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
10.1.1 IBM Video Central - business scenario . . . . . . . . . . . . . . . . . . . . . 360
10.1.2 IBM Video Central architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
10.1.3 IBM XML and Web Services Development Environment . . . . . . . 364
10.2 Application design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
Contents vii
10.2.1 Class definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
10.2.2 Database design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
10.3 Installation and verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
10.3.1 Enabling the DB2 environment for IBM VideoCentral . . . . . . . . . . 381
10.3.2 WebSphere Studio Application Developer . . . . . . . . . . . . . . . . . . 388
10.3.3 Preparing the project in Application Developer . . . . . . . . . . . . . . . 391
10.3.4 Deployment to WebSphere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
10.3.5 Deploy the Web Services into WebSphere . . . . . . . . . . . . . . . . . . 401
10.3.6 Creating and running a sample client . . . . . . . . . . . . . . . . . . . . . . 408
10.3.7 Running the sample client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
10.3.8 Solving common problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Figures ix
5-2 Java for transaction processing and messaging . . . . . . . . . . . . . . . . . 123
6-1 WebSphere programming environment . . . . . . . . . . . . . . . . . . . . . . . . 126
6-2 Web-based application architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . 129
6-3 Distributed object-based application architecture . . . . . . . . . . . . . . . . 130
6-4 Web-based distributed application architecture . . . . . . . . . . . . . . . . . . 131
6-5 Servlet runtime model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
6-6 Life cycle of servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
6-7 JSP request through browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
6-8 Life cycle of JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
6-9 HTML page SimpleHTTPServlet generates. . . . . . . . . . . . . . . . . . . . . 140
6-10 SimpleHTTPServlet code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
6-11 Servlet SmartGuide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
6-12 Configuring VisualAge for Java for WebSphere Studio interface . . . . 143
6-13 WebSphere test environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
6-14 SimpleHTTPServlet code in workbench . . . . . . . . . . . . . . . . . . . . . . . 149
6-15 Servlet engine class path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
6-16 SimpleHTTPServlet response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
6-17 default_app.webapp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
6-18 SimpleJSP response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
6-19 Export to a jar file window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
6-20 Specifying Web Module Properties panel . . . . . . . . . . . . . . . . . . . . . . 154
6-21 Add Files window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
6-22 Specifying Web Component Properties . . . . . . . . . . . . . . . . . . . . . . . . 156
6-23 Select file for Class name window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
6-24 Add Servlet Mappings window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
6-25 Specifying Application Properties panel. . . . . . . . . . . . . . . . . . . . . . . . 158
6-26 Confirm values window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
6-27 Specifying the Application or Module panel . . . . . . . . . . . . . . . . . . . . . 160
6-28 WebSphere Advanced Administrative Console window . . . . . . . . . . . 161
6-29 WebSphere Advanced Admin Console window. . . . . . . . . . . . . . . . . . 162
6-30 Output requested by SimpleHTTPServlet . . . . . . . . . . . . . . . . . . . . . . 163
7-1 Group memberships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
7-2 Choose destination window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
7-3 Setup type window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
7-4 Information for Service Setup window . . . . . . . . . . . . . . . . . . . . . . . . . 176
7-5 Welcome page of IBM HTTP Server . . . . . . . . . . . . . . . . . . . . . . . . . . 177
7-6 Select Products window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
7-7 Select Installation Type window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
7-8 Choose Destination window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
7-9 Enter username and password for Control Center Server . . . . . . . . . . 181
7-10 Install OLAP Starter Kit window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
7-11 Choose Destination Location window - install WAS4_FP3 . . . . . . . . . 182
7-12 Choose Destination Location window - install fixpack 4 . . . . . . . . . . . 183
Figures xi
9-15 Logic flow of a Web service using SOAP. . . . . . . . . . . . . . . . . . . . . . . 353
10-1 IBM VideoCentral business overview . . . . . . . . . . . . . . . . . . . . . . . . . 361
10-2 Web Services provider, requester, and broker . . . . . . . . . . . . . . . . . . 363
10-3 IBM Video Central Web service architecture overview . . . . . . . . . . . . 364
10-4 Sequence diagram for Add Customer Infraction . . . . . . . . . . . . . . . . . 370
10-5 Sequence diagram for Query Customer Infraction . . . . . . . . . . . . . . . 372
10-6 Class diagram for Customer Infraction Web service . . . . . . . . . . . . . . 373
10-7 Sequence diagram for Add Wish List. . . . . . . . . . . . . . . . . . . . . . . . . . 375
10-8 Class diagram for Wish List Web service . . . . . . . . . . . . . . . . . . . . . . 377
10-9 IBMVideoCentral overall class diagram . . . . . . . . . . . . . . . . . . . . . . . . 378
10-10 Diagram of the logical data model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
10-11 Configuring the server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
10-12 Server instance created . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
10-13 Configuring the data source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
10-14 Add external .jar files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
10-15 Adding the Web project to the server. . . . . . . . . . . . . . . . . . . . . . . . . . 397
10-16 Properties for the VideoCentral Web project . . . . . . . . . . . . . . . . . . . . 397
10-17 Before importing the .jar files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
10-18 Select resources to import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
10-19 After preparing Video Central project. . . . . . . . . . . . . . . . . . . . . . . . . . 400
10-20 Selecting the Web Service to be deployed . . . . . . . . . . . . . . . . . . . . . 402
10-21 Java Bean to be deployed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
10-22 Configuring the Java Bean as a Web service . . . . . . . . . . . . . . . . . . . 404
10-23 Select the public methods to deploy . . . . . . . . . . . . . . . . . . . . . . . . . . 405
10-24 Web Service binding proxy generation . . . . . . . . . . . . . . . . . . . . . . . . 406
10-25 Content of WSDL file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
10-26 All Web Services deployed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
10-27 Components of Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
10-28 Class diagram for Video Centrals sample client, VideoClient . . . . . . . 410
10-29 Sequence diagram for Video Central’s sample client, Video Client . . . 411
10-30 Add external JAR files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
10-31 Adding the Client Web Project to the server . . . . . . . . . . . . . . . . . . . . 413
10-32 Highlight source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
10-33 Importing the client code from a .zip file into VideoClient . . . . . . . . . . 415
10-34 Highlight webApplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
10-35 File system window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
10-36 Successful import of Video Central’s Client, VideoClient. . . . . . . . . . . 418
10-37 Generating the BusinessRegistrationProxy . . . . . . . . . . . . . . . . . . . . . 419
10-38 Checkpoint for creating proxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
10-39 Adding the client servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
11-1 JDBC trace point example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
11-2 Contents for common section of CLI configuration . . . . . . . . . . . . . . . 432
11-3 CLI trace point example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Figures xiii
xiv DB2 UDB e-business Guide
Tables
Tables xv
xvi DB2 UDB e-business Guide
Notices
This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in other countries. Consult
your local IBM representative for information on the products and services currently available in your area.
Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM
product, program, or service may be used. Any functionally equivalent product, program, or service that
does not infringe any IBM intellectual property right may be used instead. However, it is the user's
responsibility to evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in this document.
The furnishing of this document does not give you any license to these patents. You can send license
inquiries, in writing, to:
IBM Director of Licensing, IBM Corporation, North Castle Drive Armonk, NY 10504-1785 U.S.A.
The following paragraph does not apply to the United Kingdom or any other country where such
provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION
PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer
of express or implied warranties in certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically made
to the information herein; these changes will be incorporated in new editions of the publication. IBM may
make improvements and/or changes in the product(s) and/or the program(s) described in this publication at
any time without notice.
Any references in this information to non-IBM Web sites are provided for convenience only and do not in any
manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the
materials for this IBM product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it believes appropriate without
incurring any obligation to you.
Information concerning non-IBM products was obtained from the suppliers of those products, their published
announcements or other publicly available sources. IBM has not tested those products and cannot confirm
the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on
the capabilities of non-IBM products should be addressed to the suppliers of those products.
This information contains examples of data and reports used in daily business operations. To illustrate them
as completely as possible, the examples include the names of individuals, companies, brands, and products.
All of these names are fictitious and any similarity to the names and addresses used by an actual business
enterprise is entirely coincidental.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which illustrates programming
techniques on various operating platforms. You may copy, modify, and distribute these sample programs in
any form without payment to IBM, for the purposes of developing, using, marketing or distributing application
programs conforming to the application programming interface for the operating platform for which the
sample programs are written. These examples have not been thoroughly tested under all conditions. IBM,
therefore, cannot guarantee or imply reliability, serviceability, or function of these programs. You may copy,
modify, and distribute these sample programs in any form without payment to IBM for the purposes of
developing, using, marketing, or distributing application programs conforming to IBM's application
programming interfaces.
The following terms are trademarks of International Business Machines Corporation and Lotus Development
Corporation in the United States, other countries, or both:
ActionMedia, LANDesk, MMX, Pentium and ProShare are trademarks of Intel Corporation in the United
States, other countries, or both.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the
United States, other countries, or both.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun
Microsystems, Inc. in the United States, other countries, or both.
C-bus is a trademark of Corollary, Inc. in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
SET, SET Secure Electronic Transaction, and the SET Logo are trademarks owned by SET Secure
Electronic Transaction LLC.
Other company, product, and service names may be trademarks or service marks of others.
This IBM Redbook examines the IBM approach to e-business and discusses how
the products in the DB2/WebSphere family provide solutions to your e-business
challenges. It also looks at some of the other tools available with WebSphere and
how they fit into IBM’s overall approach.
Chapter 3 provides an overview of the products and tools available for developing
Java applications within a DB2/WebSphere environment.
Chapter 11 discusses the basics of how to setup four common traces in DB2,
which are necessary to problem determination in DB2 and WebSphere.
Jeffrey Rodrigues
Stewart Tates
Gary Wilmot
Susan Malaika
IBM Silicon Valley Laboratory, San Jose, USA
Preface xxi
Manmeet Ahluwalia
Vijay Marwaha
IBM Global Services, New York, USA
Iain Boyle
IBM Hursley, United Kingdom
Debra Erickson
Shawn Lauzon
Melissa Modjeski
IBM Rochester, USA
Kalyan Narayanan
Freelance Enterprise Systems Architect
Santosh Kulkarni
Freelance DB2 Database Consultant
Notice
This publication is intended to help professional Java Programmers, Database
Administrators, System Administrators and System Designers to deploy
e-business applications using DB2 Universal Database (UDB) Extended Edition
(EE) Version 7 and WebSphere Advanced Edition Version 4.0. The information in
this publication is not intended as the specification of any programming interfaces
that are provided by DB2 Universal Database (UDB) Extended Edition (EE)
Version 7 and WebSphere Advanced Edition Version 4.0. See the
PUBLICATIONS section of the IBM Programming Announcement for DB2
Universal Database (UDB) Extended Edition (EE) Version 7 and WebSphere
Advanced Edition Version 4.0 for more information about what publications are
considered to be product documentation.
Comments welcome
Your comments are important to us!
Preface xxiii
xxiv DB2 UDB e-business Guide
1
Chapter 1. Introduction
IBM e-business is a major initiative. IBM WebSphere software platform for
e-business is a comprehensive set of award-winning software and integrated
e-business solutions. It is a software platform based on industry standards like
Java, XML and J2EE technologies. Deep support of these features within DB2 is
essential for deploying e-business applications with DB2. DB2 Universal
Database (UDB) supports all the key Internet standards, making it an ideal
database for use on the Web. It has in-memory speed to facilitate Internet
searches and complex text matching combined with the scalability and
availability characteristics of a relational database. DB2 Universal Database
supports WebSphere, Java, and XML Extender, which makes it easy for you to
deploy your e-business applications.
This redbook examines the IBM approach to e-business and discusses how the
products in the DB2/WebSphere Family provide solutions to your e-business
challenges. It also looks at some of the other tools available with the WebSphere
Family and how they fit into IBM’s overall approach.
This book starts by providing an overview of how the Java environment is set up
during DB2 installation, how to change these defaults and the additional
configuration options to run Java programs. We describe the JDBC and SQLJ
interfaces and how to call stored procedures and user defined function from Java
programs. We also look at the products and tools available for developing Java
applications within a DB2/WebSphere environment.
This book provides a complete working application the "IBM Video Central",
including a step-by-step guide designed to demonstrate DB2 as a Web service
provider, and the WebSphere Studio Application Developer toolkit. Specifically,
the case study demonstrates a Web service built with technologies including:
Simple Object Access Protocol (SOAP), Web Services Description Language
(WSDL), and Universal Description, Discover and Integration (UDDI)
specification.
This book discusses the basics of how to setup four common traces in DB2: CLI
Trace, JDBC Trace, db2trc, ddcstrc, db2diag.log. Finally the book covers some
of the patches and prerequisites required for such things as using an enterprise
system to store the WebSphere repository database.
Chapter 1. Introduction 3
4 DB2 UDB e-business Guide
2
Also contained in this chapter are descriptions of the JDBC and SQLJ interfaces
and how to call stored procedures and user defined function from Java programs.
The APIs are defined within 16 interfaces and classes that support basic SQL
functionality for connecting to a database, executing SQL statements, and
processing results. Together, these interfaces and classes represent the JDBC
capabilities by which a Java application can access relational data.
DB2's Java support includes JDBC, a vendor-neutral dynamic SQL interface that
provides data access to your application through standardized Java methods.
JDBC is similar to DB2 CLI in that you do not have to precompile or bind a JDBC
program. As a vendor-neutral standard, JDBC applications offer increased
portability.
Java Application/Applet
4 defined
JDBC
Driver Types:
JDBC API
JDBC-ODBC DB Protocol
Partial Java
Bridge
ODBC DB
DB Lib
Driver Middleware
Note: DB2 provides implementations for JDBC driver type 2 and type 3. With
DB2 UDB version 8 a JDBC driver type 4 will be made available.
JDBC 2.0 is divided into the JDBC 2.0 Core API, which is a superset of JDBC
1.0, and the JDBC 2.0 Optional Package API, which provides support for JNDI
(Java Naming and Directory Interface), connection pooling, and JTA (Java
Transaction API).
The following code fragment (Example 2-1) shows a simple example of obtaining
and using a connection directly through a JDBC driver.
Example 2-1 JDBC 2.0 Core API connection code example
try {
//establish a connection through the DriverManager
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
String url = "jdbc:db2:sample";
String username = "dbuser";
String password = "passwd";
java.sql.Connection conn =
java.sql.DriverManager.getConnection(url,username,
password);
//query the database
java.sql.Statement stmt = conn.createStatement();
java.sql.ResultSet rs =
stmt.executeQuery("SELECT EMPNO, FIRSTNME, LASTNAME
FROM EMPLOYEE");
In the example code the first action is to establish a connection to the database.
This is done by loading and registering the JDBC driver and then requesting a
connection from DriverManager.
DriverManager is a JDBC 1.0 class and is the basic service for managing a set
of JDBC drivers.
Lastly, the results are processed by stepping through the result set and pulling
the data from each record retrieved.
In JDBC 1.0 and the JDBC 2.0 Core API, DriverManager was used exclusively
for obtaining a connection to a database. The database URL, username, and
password were used in the getConnection request. In the JDBC 2.0 Optional
Package API, the datasource provides a new means of obtaining connections to
a database.
The benefit of using the DataSource model is the creation and management of
the connection factory is centralized. Applications do not need to have specific
information such as the database name, user name, or password in order to
obtain a connection to the database.
The steps for obtaining and using a connection in the JDBC 2.0 Optional
Package API paradigm differ slightly from the JDBC 2.0 Core API example.
The following code fragment (Example 2-2) shows how to obtain and use a
connection in the JDBC 2.0 Optional Package API through a datasource defined
in the WebSphere Application Server packages:
Example 2-2 JDBC 2.0 Optional API connection code example
try {
6.//Retrieve a DataSource through the JNDI Naming Service
java.util.Properties parms = new java.util.Properties();
parms.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
//Create the Initial Naming Context
javax.naming.Context ctx = new
javax.naming.InitialContext(parms);
//Lookup through the naming service to retrieve a
//DataSource object
//In this example, SampleDB is the datasource
javax.sql.DataSource ds =
(javax.sql.DataSource)
In the code example (Example 2-2) the first action is to retrieve a DataSource
object from the JNDI name space. This is accomplished by creating a Properties
object of parameters used to set up an InitialContext object. Once a context is
obtained, a lookup on the context is performed to find the specific datasource
necessary, in this case, the SampleDB datasource.
In this example, it is assumed the data source has already been created and
bound into JNDI by the WebSphere administrator.
Important: In contrast to the JDBC 2.0 Core API example, the connection
obtained in this example (Example 2-2) from the datasource is a pooled
connection. This means that the Connection object is obtained from a pool of
connections managed by WebSphere connection pooling.
Both lookups work in Version 4.0, but all new applications should be written with
the version 4.0 syntax, which is the J2EE 1.2-compliant lookup method.
For more information on the details on the JDBC 2.0 Core Package API and the
JDBC 2.0 Optional Package API, refer to the JDBC 2.0 Optional Package API
Specification at http://java.sun.com
The following section tells you how to check which JDBC driver that DB2 is
currently configured to use.
The version of JDBC being used is significant in the functions supported by the
APIs it contains. In order to use WebSphere connection pooling you must be
using JDBC 2.0.
Figure 2-2 illustrates how the JDBC applet driver, also known as the net driver,
works. The driver consists of a JDBC client and a JDBC server. The JDBC server
process is db2jd.
The JDBC client driver is loaded on the Web browser along with the applet.
When the applet requests a connection to the DB2 database, the client opens a
TCP/IP socket to the JDBC server on the machine where the Web server is
running.
The JDBC server then makes corresponding CLI (ODBC) calls to perform the
task. Upon completion, the JDBC server sends the results back to the client
through the connection.
SQLJ applets add the SQLJ client driver on top of the JDBC client driver. Apart
from this added layer SQLJ client/server dialogues work the same way.
SQLJ
HTTPd
Applet
SQLJ
JDBC Server
Run-Time Classes Local DB2
Database
CLI
HTTP
Java/
JDBC TCP/IP
JDBC
Client Socket
Applet
Remote DB2
Database
FixPak levels
It is essential that the db2java.zip file used by the Java applet be at the same
FixPak level as the JDBC applet server. Under normal circumstances,
db2java.zip is loaded from the Web Server where the JDBC applet server is
running. This ensures a match. If, however, your configuration has the Java
applet loading db2java.zip from a different location, a mismatch can occur.
If a mismatch occurs, the JDBC applet server logs one of the following messages
in the jdbcerr.log file:
If the JDBC applet server is at DB2 Version 7 FixPak 2 or later:
jdbcFSQLConnect: JDBC Applet Server and client (db2java.zip)
versions do not match. Unable to proceed with connection., einfo=
-111
If the JDBC applet server is prior to FixPak 2:
jdbcServiceConnection(): Invalid Request Received., einfo= 0
The term Java enablement is used to encompass the interfaces that Java uses to
communicate with DB2 databases, the components within the DB2 product that
support Java development and the components that are configured to support
the runtime environment.
SQLJ applications use this JDBC support, and in addition require the SQLJ
run-time classes to authenticate and execute any SQL packages that were
bound to the database at precompiling and binding stage.
The third component of DB2 Java support, stored procedures and UDF’s reside
on the DB2 server. These stored procedures and UDF’s can be called by both
client and server side applications using the Type 2 and Type 3 JDBC drivers, as
well as non-Java applications.
SQLJ
Application
SQLJ
Run-Time Classes
Remote
Database
Java
JDBC DB2 Client
Application
AIX
Here are the steps to install and configure a Java environment on AIX.
To switch between using the JDBC version 1.22 driver and the JDBC version 2.0
driver see “Changing the version of JDBC that DB2 is using” on page 13.
Configure CLASSPATH
In order to run JDBC and SQLJ programs on AIX with DB2 JDBC support,
commands to update the AIX Java environment are included in the database
manager files db2profile and db2cshrc.
When a DB2 instance is created, .profile and/or .cshrc are modified so that the
CLASSPATH includes:
"." (current directory)
the sqllib/java/db2java.zip file
To switch between using the JDBC Version 1.22 driver and the JDBC version 2.0
driver see “Changing the version of JDBC that DB2 is using” on page 13.
Configure CLASSPATH
In order to run JDBC and SQLJ programs on the Windows with DB2 JDBC
support, commands to update the Windows Java environment are automatically
updated when DB2 is installed.
When using an SQLJ application to access a DB2 server, a program will execute
SQL statements with the privileges assigned to the userid who created the
database package.
2.3 SQLJ
This section gives an overview and detail about SQLJ support in the DB2
environment.
The SQLJ environment consists of a translator (written in Java) and a set of Java
classes that implement SQLJ’s runtime support (see Figure 2-3).
SQLJ is designed with specific goals in mind. The main goal is to provide simple
extensions to Java to allow rapid development and easy maintenance of Java
applications that use embedded SQL to interact with databases.
The SQLJ support provided by the DB2 Application Development Client includes:
The SQLJ translator, SQLJ, which replaces embedded SQL statements in
the SQLJ program with Java source statements and generates a serialized
profile containing information about the SQL operations found in the SQLJ
program.
The SQLJ translator uses the sqllib/java/sqlj.zip file.
The SQLJ run-time classes, available in sqllib/java/runtime.zip.
The DB2 SQLJ profile customizer, db2profc, which precompiles the SQL
statements stored in the generated profile and generates a package in the
DB2 database.
The DB2 SQLJ profile printer, db2profp, which prints the contents of a DB2
customized profile in plain text.
The SQLJ profile auditor installer, profdb, which installs (or un-installs)
debugging class-auditors into an existing set of binary profiles. Once
installed, all RTStatement and RTResultSet calls made during application run
time are logged to a file (or standard output), which can then be inspected to
verify expected behavior and trace errors. Note that only those calls made to
the underlying RTStatement and RTResultSet call interface at run time are
audited.
The SQLJ profile conversion tool, profconv, which converts a serialized
profile instance to class bytecode format. Some browsers do not yet have
support for loading a serialized object from a resource file associated with the
applet. As a work-around, you need to run this utility to perform the
conversion.
For more information on the db2profc and db2profp commands, refer to the DB2
UDB Application Development Guide.
For more information on the SQLJ run-time classes, refer to the DB2 Java Web
site at http://www-4.ibm.com/software/data/db2/java/
Stored procedures may have IN, OUT, or INOUT parameters. In Example 2-3,
the value of host variable myarg is changed by the execution of that clause.
An SQLJ executable clause may call a function by means of the SQL VALUES
construct.
For example, assume a function F that returns an integer. The following example
(Example 2-4) illustrates a call to that function that then assigns its result to Java
local variable.
Example 2-4 Calling a function from SQLJ
x:
{
int x;
#sql x = { VALUES( F(34) ) };
}
2. Install DB2 SQLJ Customizers on generated profiles and create the DB2
packages in the DB2 database dbname:
db2profc -user=user-name -password=user-password
-url=jdbc:db2:dbname -prepoptions="bindfile using MyClass0.bnd
package using MyClass0" MyClass_SJProfile0.ser
db2profc -user=user-name -password=user-password
-url=jdbc:db2:dbname -prepoptions="bindfile using MyClass1.bnd
package using MyClass1" MyClass_SJProfile1.ser
3. Execute the SQLJ program:
java MyClass
The translator generates the SQL syntax for the database for which the SQLJ
profile is customized. For example:
i = { VALUES ( F(:x) ) };
This is translated by the SQLJ translator and stored as this in the generated
profile:
? = VALUES (F (?))
When connecting to a DB2 Universal Database database, DB2 will customize the
VALUE statement into:
VALUES(F(?)) INTO ?
Hewitt, Randall H. Across the plains and over the divide: a mule
train journey from East to West in 1862, and incidents connected
therewith. $1.50. Broadway pub.
The untamed West of the Civil war days, with its primitive
grandeur and unrestraint is reproduced in these pages for the
benefit of the younger generation. The journey covers a zigzag
course from Illinois to Washington, over wild country, with no end
of perilous encounters.
+ Pub. Opin. 40: 638. My. 19, ’06. 970w. (Review of v. 1–9.)
+ + – Ann. Am. Acad. 27: 248. Ja. ’06. 570w. (Review of v. 1.)
“On the whole the book has the qualities of a competent
American work, being well written, but a little dull, very dependent
on European scholarship, and lacking in freshness.”
+ + – Ath. 1905, 2: 334. S. 9. 310w. (Review of v. 1.)
“It is valuable, however, for bringing into one view the larger
facts of the period treated, and emphasizing their influence upon
the growth of national states.” David Y. Thomas.
“The public which delights in his writing will be just the public
that can only pretend to admire the artists of his choice.”
ebookbell.com