Nonstop Database, HiRDB Version 9 Description

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

5.4.5 External Java stored routine creation and execution procedure

The following is the general procedure for creating and executing an external Java stored routine.

Procedure
  1. Create an external Java stored routine.
  2. Register a new JAR file.
  3. Define the external Java stored routine.
  4. Execute the external Java stored routine.

The following figure shows the flow of events from the creation of an external Java stored routine to its execution.

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

[Figure]

Organization of this subsection
(1) Coding an external Java stored routine
(2) Registering a new JAR file
(3) Defining the external Java stored routine
(4) Executing the external Java stored routine

(1) Coding an external 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 a new JAR file

In this step, you register the new JAR file in HiRDB.

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

Registration by the UAP developer:
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 external Java stored routine

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

(4) Executing the external 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 external Java stored routine is executed on the Java virtual machine at the server.