HP Driver for JDBC User's Manual
Chapter 4 33
Using the HP Driver for JDBC
Sample JDBC Client
Sample JDBC Client
The HP Driver for JDBC comes with the source code to two JDBC
applications, a sample client and a simple client. Both can be used to
test the installation of JDBC components on the client and server.
The simple client is called SimpleClient and is a bare-bones text-based
application that makes a connection to an ALLBASE/SQL or
IMAGE/SQL database, and allows the user to send SQL statements
and retrieve the results. There are no frills in the application, so as to
make the code as simple as possible. This client should mainly be used
for educational purposes. The rest of this discussion will focus on the
more robust application.
The sample client is called SampleClient and is a more robust version
of the simple client. It shows how to use a dialog box to obtain user
input, and also better formats the result set output.
The first step using the sample client is to build it by compiling the
Java source code. Normally, you would do this by using the Java
compiler command (the command you use may be different, depending
on your JDK):
javac SampleClient.java
If this step fails, then you most likely do not have the HP Driver for
JDBC class files in your class path. Set your CLASSPATH environment
variable or use the -classpath Java compiler option to include the
directory in which the driver class files are located. For more
information, refer to your JDK documentation on including other class
files.
Once the Java compiler has compiled the source file, the following Java
class file will be created:
SampleClient.class
To run the sample client, follow the instructions provided with your
Java SDK for your client platform. Make sure that your Java
CLASSPATH includes the directory in which the HP Driver for JDBC
class files have been installed, so that the Java Virtual Machine is able
to load them. For most platforms, the command to run the sample
client is:
java SampleClient [-w] [-t]
Follow the prompts given by the application to connect to your database
and to execute SQL statements.
The sample client can be used as a starting point for developing your
own applications or for troubleshooting connection problems with the
database.