Communicator e3000 MPE/iX Release 6.5 (Non-Platform Software Release C.65.00 (30216-90291)
154 Chapter5
Internet and Interoperability
HP Driver for JDBC
It shows how to use a dialog box to obtain user input, and also formats the result set
output a lot better.
The first step to 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):
NOTE
If you are using JDK1.2.1 or later, add the following line in SampleClient.java
before the call to class.forName:
DriveManager.setLogStream(System.Out);
javac SampleClient.java
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.
Loading the HP Driver for JDBC
The Java method that is used to load all JDBC drives is the class.forName method. To
load the HP Driver for JDBC, the code is:
class.forName(“com.hp.jdbc.allbase.JdbcDriver”);
This loads the HP Driver for JDBC and registers it with the JDBC Driver Manager. Once a
driver has been loaded and registered with the Driver Manager, it is ready to be used to
connect to a database.
URL Syntax (Including User Name and Password)
The first connection method specifies all connection parameters, including the user name
and password, in an URL string.
java.sql.DriverManager.getConnection(url)
where:
String url =
“jdbc:allbase://
host
[:
port
]/
database
?UID=
uid
&PWD=
pwd
”
“[&TRACE=
trace
]”;
host
Name or IP address of the sever host.
port
Optional port number on which the JDBC Monitor is listening. If not
specified, the default part number 31700 is used.
database
ALLBASE/SQL or IMAGE/SQL database name.