DB2 Connect User's Guide

DB2 Connect and Web Applications

The web browser is rapidly becoming a standard interface for everything from on-line catalogs to intranet applications. For simple web applications, a web server alone may be sufficient. For high-volume applications that may require database access and transaction processing, IBM offers solutions that use DB2 Connect to manage very high numbers of simultaneous transactions over the web.

This section describes web-based business solutions that can benefit from using DB2 Connect.

Advantages and Limitations of Traditional CGI Programming

e-business applications on the World Wide Web typically use the Common Gateway Interface (CGI) to enable users to query back-end databases. Many companies also use web applications internally, and these usually have a database in the background as well.

Users fill out forms on a web page, and these forms are submitted via CGI to applications or scripts on the web server. The script will in turn use a provided database API to submit SQL queries to a host database. The same script can then build a web (HTML) page with results of the query and send it back to be displayed by the user's web browser. For example, an on-line catalog, in which the user can query the availability and current price of particular goods or services.

CGI applications can be simple to design and easy to maintain. Since the CGI standard is both operating system- and language-independent, it is available on nearly all computing platforms. CGI programs can be written in C++, or in a scripting language such as Perl.

While CGI may seem like an ideal solution for web-based applications, it has significant shortcomings. The programming environment for CGI is not as sophisticated as other APIs. In addition, there is a scalability issue that will affect any large-scale e-commerce operation. Every time a CGI application is invoked, a new process is created on the web server. Each instance must make its own connection to the database, and each instance submits its own query. In high-volume transactional environments, this limitation can create significant performance issues.

You can use DB2 Connect with a web server to create robust, high-volume e-commerce applications. DB2 Connect provides several solutions that improve web-based application performance. Stored procedures (see DB2 Connect on the Web Server) allow DB2 Connect users to reduce the number of queries being sent to the database.

Connection pooling (see Connection Pooling) reduces the frequency of connections and disconnections to and from a database. For large operations where the limitations of CGI become important, see IBM Net.Data (see Net.Data) and WebSphere (see IBM WebSphere) provide non-CGI connections to large enterprise applications.

DB2 Connect on the Web Server

IBM provides HTTP (Web) servers with all DB2 Connect products for OS/2, UNIX, Windows NT, and Windows 2000. DB2 Connect Enterprise Edition provides out-of-the-box support for Apache or Lotus Domino Go web servers and can also work with any other web server such as Microsoft Internet Information Server or Netscape Enterprise Server.

If you are working with the DB2 family of databases running on OS/390, AS/400, VM, and VSE systems, DB2 Connect Enterprise Edition is required on the Web server. DB2 Connect Enterprise Edition will provide the libraries and communication interfaces to enable Web servers to access these host and AS/400 platforms. Either TCP/IP or SNA can be used to communicate between the Web server and a database running on OS/390, AS/400, VM or VSE.
Note:IBM web solutions provide the ability to work with multiple databases within the same CGI script or within the same transaction in a CGI script.

The next two sections discuss performance enhancements available to CGI applications that access DB2 databases. Later sections will explore alternatives to standard CGI such as Java.

Stored Procedures

An important consideration for web applications, as in the client/server world, is to minimize the traffic that occurs between the HTTP server and the back end database. This consideration is particularly important in high-volume transactional processing, which is the heart of most e-business applications.

The recommended approach is to combine CGI application programming with the programming and business logic encapsulated in stored procedures. DB2 Universal Database on OS/2, UNIX, and Windows, and DB2 on OS/390, AS/400 and VSE all share the same parameter convention for invoking stored procedures.

As with regular CGI, the web browser submits the form to the web server, where the CGI script is run. However, instead of each individual SQL statement being sent to the DB2 database, a request to execute a stored procedure is sent. This stored procedure encapsulates a number of SQL statements that would have otherwise been run individually. Stored procedures reduce the number of messages flowing back and forth between the CGI script and the back end database.

The key benefit of stored procedures is reduced network traffic between the HTTP server and the DB2 database back end. For more information about stored procedures, refer to the Application Development Guide or the DB2 Stored Procedure Builder online help.

Connection Pooling

Establishing a connection from a DB2 Connect server to the host requires computing resources and time. In an environment where thousands of clients frequently connect to and disconnect from the host through the DB2 Connect server, a substantial portion of processing time is spent in establishing connections and dropping connections.

DB2 Connect's connection pooling provides a significant performance improvement in such environments. DB2 Connect maintains open connections to the database in an available pool. When a client requests a connection, it can be provided from this pool of ready connections. Connection pooling significantly reduces the overhead typically spent on opening and closing these connections.

For more information on how connection pooling works, see Connection Pooling.

DB2 Connect as a Java Application Server

Many of the shortcomings of CGI can be overcome by moving away from it and using Java instead. IBM provides both applets and applications that allow you to substitute Java for CGI at every stage of a web transaction. The solutions IBM provides allow for a mix of techniques, which means you can use scripting solutions such as Net.Data and Microsoft Active Server Pages with DB2, or move towards a more robust implementation provided by a Java application server such as IBM WebSphere.

There are two Application Programming Interfaces (APIs) for Java programmers. The first, JDBC, is supported for using Java to develop data-aware Java Applets, Java Applications as well as Java servlets, Java server pages (JSP) and Enterprise Java Beans (EJB). JDBC is a call-level or method invocation API. The other Java API is SQLJ. SQLJ provides the ability to specify SQL in-line within a Java program. DB2 can use both APIs, on either the client or server side of a web transaction.

On the client side, applets, data-aware applets, and applications are supported. On the database side Java enablement consists of database objects, such as user-defined functions and stored procedures.

For DB2 for OS/390, DB2 for VSE and VM, and DB2 for OS/400, there are two different ways to deploy a Java application. You can use the direct connectivity provided by DB2 Connect Personal Edition with TCP/IP or SNA, or you can choose to go through a DB2 Connect Enterprise Edition server that will provide connectivity to the mainframe or the AS/400 back end.

In both cases, the user on the Web does not require any special software to access the database, only a standard web browser. The only thing that needs to be installed is a DB2 Connect server and any industry standard Web server. If the web server and DB2 Connect are not on the same physical machines, a DB2 client needs to be installed on the web server.

For DB2 for OS/390 the key component is DB2 Connect Enterprise Edition running on a mid-tier server. This is the component that will provide JDBC server enablement, in addition to connecting to the DB2 for OS/390, VSE and VM, or AS/400 server. Again, there is no need for any special software for the client's web browser.

IBM provides an extensive set of tools for developing Java applications and applets. For database connectivity, DB2 Developer's Edition provides a complete kit containing VisualAge for Java Professional Edition, WebSphere Application Server, Net.Data, as well as DB2 Universal Database and DB2 Connect for testing. IBM VisualAge for Java Enterprise Edition also contains development tools for large-scale enterprise applications. Third-party tools such as Borland JBuilder or Symantec Visual Cafe will also work with IBM's database solutions.

Net.Data

Net.Data, part of the DB2 Universal Database and DB2 Connect family, is a set of application development tools designed to help you create and maintain web-based transaction applications. You can use Net.Data to access and alter data stored on a DB2 UDB for OS/2, Windows NT, Windows 2000, UNIX, OS/390, VM, VSE, and OS/400. The applications you create using Net.Data are stored on a web server and can be activated through a web browser.

Net.Data uses macros, or templates, to allow users with a basic understanding of HTML and SQL to build very sophisticated web applications. A macro is a text file that can be composed of Java, Java Scripts, HTML tags, and built-in functions. These macros can then be used to generate dynamic web pages with predefined layout, variables, and functions.

A basic Net.Data macro has seven distinct sections:

The key feature of Net.Data, specifically for DB2, is that there is no client deployment required. The client in this implementation is simply a web browser.

The Net.Data processor is installed together with the DB2 Universal Database on a Windows NT, Windows 2000, OS/2, or UNIX workstation along with the Web server. When connecting to DB2 OS/390, DB2 for VSE and VM, and 400, all of the Net.Data infrastructure is deployed on a DB2 Connect server, along with a Web server.

IBM WebSphere

IBM WebSphere provides a more complete e-business solution than is possible with traditional CGI programming. WebSphere application servers not only perform the scripting possibilities of CGI, but also allow you to provide complex and high-end services through the web, using servlets, Active Server Pages, and enterprise JavaBeans. With WebSphere you can:

WebSphere is not one product, but a family of three products addressing three different target markets. The heart of the WebSphere solution is the WebSphere application server.

The WebSphere application server provides the environment for three types of objects. One is Java server pages, which are analogous to Active Server Pages. The second component consists of Java servlets, and the third is enterprise JavaBeans. Enterprise JavaBeans are the emerging standard for deploying very large-scale, robust enterprise-class applications.

Additionally, Data Access JavaBeans provide very sophisticated database functions specifically tailored to DB2. DB2 is also directly accessible via JDBC and SQLJ. Both COM+ as well as CORBA are also supported.

WebSphere applications can be deployed on the same platform as the web server and DB2 Universal Database. In the case of the DB2 for OS/390, VM, VSE, and AS/400, WebSphere is deployed on the same platform as DB2 Connect Enterprise Edition.

There are several WebSphere solutions, as well as the Web Studio and WebSphere Performance Packs. The three WebSphere versions are:

Standard Edition
For Web site producers this server enables the use of Java servlets and JSP technology to quickly and easily transform Web sites and portals from static pages to vital sources of personalized dynamic Web content. It also includes industry-leading XML support for sharing information and data easily across groups or between enterprises and built-in site analysis technology that provides performance and usage information to help you maximize your company's return on its Web site investment.

Advanced Edition
For application programmers this high-performance EJB server enables deployment of business logic using EJB components. It provides scalability security connectivity and Java support and includes all of the functionality of the Standard Edition.

Enterprise Edition
For enterprise architects this server integrates disparate business systems across your organization to build robust e-business applications and maximize the reuse of resources. Enterprise Edition incorporates the capabilities of the award-wining IBM TXSeries- and Component Broker technologies. It also includes all of the functionality of the Advanced and Standard Editions.


[ Top of Page | Previous Page | Next Page ]