Scalable Database Server, HiRDB Version 8 Description

[Contents][Glossary][Index][Back][Next]

5.4.4 Java stored routine creation and execution procedure

Following is the procedure for creating and executing a Java stored routine:

Procedure
  1. Code the Java stored routine.
  2. Register into HiRDB.
  3. Define the Java stored routine.
  4. Execute the Java stored routine.

Figure 5-5 shows the flow of events from creation of a Java stored routine to its execution.

Figure 5-5 Flow from creation to execution of a Java stored routine

[Figure]

Organization of this subsection
(1) Coding a Java stored routine
(2) Registering into HiRDB
(3) Defining the Java stored routine
(4) Executing the Java stored routine

(1) Coding a Java stored routine

In this step, you code either a procedure or a function in Java, then you compile the resulting Java program. Compilation produces a Class file. You can then test and debug the Class file, using the Java virtual machine at the client, and create a JAR file from the Class file.

(2) Registering into HiRDB

In this step, you register the JAR file into HiRDB.

Registration by a HiRDB administrator:
The HiRDB administrator uses the pdjarsync command.

Registration by a programmer:
The programmer uses the INSTALL JAR or REPLACE JAR statement in the embedded language. These SQL statements can be coded in either the pddef file or the UAP, and then executed.

(3) Defining the Java stored routine

You use the CREATE PROCEDURE or the CREATE FUNCTION statement to define a Java stored routine from the JAR file.

(4) Executing the Java stored routine

As in the case of executing a stored procedure or a stored function, you execute the SQL by specifying either a CALL statement or a function call. The CALL statement causes a Java method to be executed as a Java stored procedure. The function call causes a Java method to be executed as a Java stored function. The Java stored routine is executed on the Java virtual machine at the server.