Accessing DB2 Over the Internet

 <  Day Day Up  >  

Allowing for Web-based access to valuable corporate data stored in relational databases makes this data more readily accessible to more people. Companies can obtain a competitive advantage by making their data available to employees over an intranet, or to customers and partners over an extranet.

NOTE

An intranet is a special Internet adaptation that can only be accessed by internal employees. Likewise, an extranet extends the accessibility in a secure manner only to authorized individuals.


One option IBM provides for accessing DB2 data over the Web is called Net.Data.

Using Net.Data to Connect to the Internet

Net.Data is an IBM product that provides developers the ability to build Web applications using data from DB2 and other enterprise databases. Using Net.Data, you can build interactive Web sites with data included dynamically from a variety of data sources, including relational and non-relational data and flat file data.

Net.Data is a macro processor that executes as middleware on a Web server. Using a Web browser and Net.Data, it is possible to rapidly develop applications that use the Internet as a front-end to DB2 databases.

Net.Data applications are macro files containing named sections specifying Web page text, HTML, the SQL statement to be executed, programs and scripts to be called, and application control logic.

Using Net.Data macros, you can develop programs that access and manipulate variables , call functions, and use report-generating tools. Net.Data processes the macro and produces output that can be displayed by a Web browser. Macros provide the developer with the simplicity of HTML coupled with the advanced functionality of Web server programs.

Simply stated, developers can use Net.Data to present data stored in DB2 tables to users in the style of a Web page. This lets savvy Internet users quickly come up to speed at accessing DB2 data.

Figure 17.3 outlines the flow of a Net.Data process. The entire flow can be broken down into a simple eight-step process:

  1. A user issues a request by specifying a URL in his Web browser. The URL points to a Net.Data macro.

  2. The Web server receives the request for the URL and invokes Net.Data, passing the name of the macro to be invoked.

  3. Net.Data creates the HTML for the input form and sends it to the browser via the Web server.

  4. The person using the Web browser fills in the input form and submits it to the Web server.

  5. Net.Data receives the input form and interprets it to access the requested data.

  6. Net.Data invokes the appropriate language environment. The language environment, in turn , processes the information by accessing DB2. It then returns the results to Net.Data.

  7. Net.Data creates the HTML for the output report form and sends it with the data retrieved from the database through the Web server to the Web browser.

  8. The results are formatted by the Web browser and the requesting user has retrieved DB2 data over the Web.

Figure 17.3. How Net.Data works.
graphics/17fig03.gif

Because Net.Data applications use native HTML and SQL, developers do not need to learn complex new languages and syntax to connect DB2 databases to the Web. Furthermore, SQL SELECT , INSERT , UPDATE , and DELETE statements are supported for both data query and modification.

You can use Net.Data to support two-tier and three-tier client/server environments. In a two-tier environment, the database resides on the Internet server and client Web browsers access the data. For DB2 running on OS/390, this is applicable only if you use the mainframe as your Internet server. In a two- tier z/OS environment, Net.Data communicates with DB2 for z/OS through RRS or the Call Attach Facility (CAF).

In a three-tier environment, the data can reside on both the local Internet server and a remote platform. This requires DB2 Connect, CAE (Client Application Enabler), or DataJoiner. The three-tier setup is useful when your Internet server is a Unix or Windows NT machine, and you need to access DB2 data from the mainframe.

In a three-tier environment, Net.Data macros can access a variety of data sources such as DB2, Oracle, Sybase, and ODBC. In a two-tier environment, Net.Data for z/OS can access DB2 for z/OS and IMS.

Net.Data Guidelines

The following guidelines can help you to implement Net.Data effectively in your organization.

Consider Using Stored Procedures

In addition to regular SQL SELECT , INSERT , UPDATE , and DELETE statements, Net.Data can invoke stored procedures. Consider calling stored procedures to quickly extend the functionality of Net.Data applications. Furthermore, stored procedures use static SQL, which, at times, can provide enhanced performance. Stored procedures also can be used to minimize network traffic.

Finally, remember that DB2 stored procedures can return result sets, if necessary.

Provide Net.Data Macro Language Training

Net.Data programs are written in Net.Data's macro language. A Net.Data macro is a mixture of HTML and Net.Data-specific keywords. Although macros can be easy to develop, it is wise to provide an appropriate level of Net.Data macro language training for your Net.Data developers before they develop any Net.Data applications.

Net.Data macros can invoke programs written in other languages, such as Perl, REXX, and C. Net.Data also can be used to invoke DB2 stored procedures. Keep in mind that these features can complicate relatively simple Net.Data macros.

Enhance Net.Data Using Java Applets and JavaScripts

Net.Data provides Java applet and JavaScript interfaces to enhance the Web client's ability to perform client-side processing. You can use a Java applet to enhance the results of a Net.Data application with graphical elements such as charts and graphs.

IBM provides sample Java applets and JavaScripts on the Net.Data Web site at the following link:

http://www.ibm.com/software/data/net.data/

Use Direct Requests When Possible

Direct requests improve performance because Net.Data does not have to read and process a macro file. The SQL, ODBC, System, Perl, and REXX Net.Data-supplied language environments support direct requests.

Consider Net.Data Live Connections

Before a query can be executed, the process must identify itself and connect to DB2. This can cause performance problems.

Net.Data can be used to establish a live connection by continuously running processes to perform the startup tasks . Once started, the process waits to execute subsequent requests.

NOTE

Live connections are required for API connections, but can be used for CGI connections, too.


Use Good Programming Techniques

Be sure to use your standard application development and programming techniques when developing Net.Data macros. Make sure to include comments in the macro file indicating the purpose of the program, as well as a log of changes.

Additionally, follow the SQL formulation guidelines covered in Chapters 1, "The Magic Words," and 2, "Data Manipulation Guidelines," and the application programming techniques outlined in Chapter 11, "Using DB2 in an Application Program."

Design Web Applications with the User in Mind

Be aware that the equipment on which you are developing your Web-based applications is probably more state-of-the-art than the equipment on which the application will be used. It is common for developers to have access to high-resolution monitors and a lot of memory. Be sure to test the application on PC setups with less memory and on monitors of varying dot pitch and resolution.

Plan Your Security Requirements

When developing DB2 applications that are accessible using the Internet, be sure to plan adequate security into the application. Net.Data provides authorization features that should be utilized to ensure that only authorized users are permitted access.

Using Java and DB2

Java is an increasingly popular language for DB2 application development. Part of its popularity is its ability to make Web applications dynamic. For Java usage guidelines, please refer back to Chapter 14, "Alternative DB2 Application Development Methods."

General DB2-Internet Guidelines

The following guidelines can be applied to DB2 applications that are written to exploit the Internet.

Minimize Network Traffic

The biggest potential for degrading the performance of DB2 Internet applications is network traffic. In general, the fewer network calls required to perform the same amount of work, the better performance will be.

Consider the following ideas for minimizing network traffic in your DB2-Internet applications:

  • Use stored procedures to process SQL and consolidate results. Stored procedures are especially helpful for pieces of code that can be executed many times from many different places. Putting the logic into a stored procedure can reduce network calls.

  • Consider using BEFORE triggers to validate data. Doing so removes the need to code intensive data validation logic running on the client.

  • Consider using user-defined functions (UDFs) to offload work from the client to the server. A good use of UDFs is to reformat data. Perhaps you have data that is stored differently than it needs to be displayed (onscreen or in a report). A UDF can be written to perform the formatting ”and that removes the need to write repetitive client code.

Keep Up-to-Date

Make sure that you are using the most up-to-date versions of software, including JDKs, drivers, and compilers. Running with outdated software likely means that you are forgoing performance upgrades that can be accrued by using the latest versions.

 <  Day Day Up  >  


DB2 Developers Guide
DB2 Developers Guide (5th Edition)
ISBN: 0672326132
EAN: 2147483647
Year: 2004
Pages: 388

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net