#

##
About the Author

My name is Sheldon Bradley Wosnick and I currently work for IBM Canada in the e-business Internet Integration department of IBM Global Services. Having had significant previous experience with Enterprise Java development , I have been on assignment for the last seven months at the Toronto IBM Lab working first on the VisualAge for Java 1.0 development team and more recently as a core Java developer on the upcoming VisualAge e-business suite which will feature, in part, VisualAge for Java 1.0 Enterprise Edition and the new release of DB2 Universal Database 5.0.

My primary responsibilities on the VisualAge for Java team involved development and software verification testing of the JDBC-ODBC Bridge, used within VisualAge for Java for enterprise database connectivity via ODBC database drivers. This involved the Java development of an entire suite of Java database test programs which exercised all aspects of the Java Database Connectivity (JDBC) API via ODBC. I have learned a great deal about VisualAge for Java, Java, JDBC and ODBC as well had the opportunity to do some serious Enterprise and Distributed Java development.

For VisualAge e-business our team is currently integrating the best-of-breed Enterprise and Web software development tools from IBM, Lotus and NetObjects. These tools are designed to meet the requirements of the professional Java developer seeking a total solution for e-business applications development. Our intention is to demonstrate how these developer tools can be combined to produce serious, real Enterprise e-business Internet and Intranet solutions. I really believe we have a winner here!

My current responsibilities include Java development of the Enterprise scenarios using IBM DB2 Universal Database 5.0 and Java server-side programming with Java servlets and CORBA distributed objects using CORBA with the Internet InterORB Protocol (IIOP) and VisualAge for Java Enterprise Edition.

Please note that I am totally representing myself here and I do not in any way represent any past, present or future views or strategies of IBM. Any and all misrepresentation of information is solely my doing. Information about either VisualAge for Java or VisualAge e-business that I have discussed here is readily available information published on our external website at www.ibm.com/java. Any code submitted is to the public domain and constitutes programming that I have done in my spare time, some before joining IBM and other done strictly offline, after hours, to expand my knowledge of servlets and server-side Java programming. (Have I been clear enough on this matter -- hopefully!).

##
Introduction

This rather simple "Universal" client HTML form is used as the front-end client to call upon the services of a 100% Pure Java servlet operating on a server back-end somewhere (which is presumably connected to some DBMS and database server). Any level of distribution is possible; for example, the servlet may call upon another servlet running on a different server which calls upon the database server etc. Alternatively, the servlet may initialize a CORBA Object Request Broker (ORB) and communicate via the Internet Inter-ORB Protocol (IIOP) with any number of fully distributed, remote objects which could perform any number and kind of operation(s) at the back-end. The uses are truly limitless! Servlets are a much better replacement for CGI/HTTP and there are a multitude of documents on the Web which testify to the superiority of the 'Pure Java' approach with servlets.

Using a servlet to perform JDBC database connectivity and database access as I have in this sample servlet means that the client downloaded to the Web browser is an "ultra thin" client -- a minimal amount of program logic (easily decompilable intellectual capital) is actually downloaded from the Web server to it resulting in less calls from the client to the server (to perform intensive database operations) and less HTTP network traffic. In addition, the intellectual capital is preserved as the client never gets any of this bytecode at the client Web browser.

##
Using the JDBC Database Access Servlet

The easiest way to try out this servlet is to to:

- Download and install the Java Servlet Development Kit (JSDK) from JavaSoft.
- Run the Servlet Runner.
- Have a database installed and an ODBC driver to access it or pure JDBC drivers (if other than DB2, will have to edit this page to add them manually to the JDBC Driver and URL choice components.)
- Load this page in any Web browser (though I only tested with Microsoft IE 4.0 and Netscape 4.02). A Java 1.1 browser is not required because all Java is done at the server-side.
- Enter ANY valid SQL query or update command supported by JDBC and process your query or update. If successful a page will be returned with the results, if not then a page will be returned stating the Java SQL exception (or other exception). I added the latter as a feature in order to get meaningful feedback back as to why the query or update failed and to recover accordingly.
- To deploy on a servlets-capable Web server (most lately) place the DataAccessServlet.class file in the place where the server looks for servlets and the client html page in the place where the server will look for html pages. Note that most browsers have problems with the JDBC-ODBC Bridge driver and it may fail or at best act unpredictably.
- Change [form action="http://localhost:8080/servlet/DataAccessServlet"] to [form action="/servlet/DataAccessServlet"] since the Web server will provide the protocol, host and port values.
- To use the servlet directly without this client form, you may pass the parameters directly in your Web browser. For example, you may pass something like the following if using the Servlet Runner -- if using a Web server, change "http://localhost:8080" to the host server name and host server port if required:

  [http://localhost:8080/servlet/DataAccessServlet?UID=swosnick&password=mypasswrd &1&database=sample&table=employee&driver=COM.ibm.db2.jdbc.app.DB2Driver &URL=DB2&action=query&SQL=select from employee where workdept = 'D11'].

###### Sheldon Bradley Wosnick, 1997. Comments and feedback welecome. EMAIL: swosnick@ca.ibm.com.

#####
n-tier (multi-tier) approach in which servlets will be important

> To use my data access servlet first enter the following connection information:

> > User ID: Password:

> Database: Table:

> JDBC Driver:
> URL:

> Query Update

> Next, enter the SQL query or command here: