Featured Whitepapers
Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Create your own type 3 JDBC driver, Part 2

Compile, deploy, and access data using your custom-built JDBC driver

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

In Part 1 of this three-part series, we showed how to construct a type 3 JDBC driver, named JWDriver, that employed RMI (Remote Method Invocation) to let the client talk to the middle tier. Continuing with JWDriver's development, in this article we explain how to compile the driver, then deploy it in a Web server environment. Further, we explain the Java files' directory structure for both the client and server tiers, then we run the driver's server tier, giving any client program access. We also include a sample Java applet (deployed on the Web server) to demonstrate how the driver can access data.

Read the whole series

This article consists of three sections: compiling, deployment, and how to create a sample Web application that employs the driver.

Compile the driver

To compile the driver, first download DriverCode.zip. Extract the files, then place them into a directory. You must compile the driver on a machine with a complete Sun Microsystems JDK (Java Developer Kit) 1.3. The DriverCode.zip file additionally contains the compile.bat file, which you should execute from the command line. The compile.bat file first sets the classpath to the local directory containing the Java files as:

set
                                       classpath=.;%classpath%
                                    


The compile.bat file then compiles the driver's Java files for the server and client tiers using javac as:

javac com\jw\server\*.java
                                       javac com\jw\client\*.java
                                    


RMI requires Stub and Skel class files for all remote interfaces exposed by the server. Prepare those files by executing the rmic command on the driver's four remote interface implementations:

rmic
                                       -d . com.jw.server.RemoteDriverImpl
                                       rmic -d . com.jw.server.RemoteConnectionImpl
                                       rmic -d . com.jw.server.RemoteStatementImpl
                                       rmic -d . com.jw.server.RemoteResultSetImpl
                                    


Deploy the driver server tier in the form of a JWServerDriver.jar file containing the server class files. To prepare the JWServerDriver.jar file, run the cvf command as indicated in compile.bat file.

Deploy the driver

You deploy JWDriver on the Web server. As such, the driver's server tier runs as an RMI server on the Web server machine, as does the driver's client tier, the sample Java applet, and the Webpage that invokes the applet. The driver's client tier and the sample Java applet reside in the same Web directory in the Web server machine. The JDBC driver client tier automatically downloads from the server to the client machine.

We made the driver Internet ready by keeping its configuration settings on the server tier, eliminating the need for any settings at the client tier. Figure 1 depicts the driver's deployment in a typical three-tier setup, with each tier on a different machine.

Figure 1. The type 3 JDBC driver's deployment. Click on thumbnail to view full-size image.

In Figure 1, the Web application deploys on the Web server machine running Microsoft Internet Information Server (IIS). The driver's server tier, configured through a properties file, communicates with the Microsoft SQL Server database.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources