Java External Procedures
This chapter describes the features and the execution of the Java External procedure.
Features
The features of the Java external procedure are as follows:
Java random classes can be called.
A class that is dynamically loadable in Java can be called using the Java external procedure.
Memory allocation for Java external procedures is different from that for Tibero
User-defined classes (User Java classes) are dynamically loaded not by a Tibero server process (server process) but by a JEPA (Java External Procedure Agent) process.
Because user Java classes are run in the memory of the JEPA process, any errors generated during execution do not affect server processes.
Privileges can be granted.
User Java classes are recognized as PSM in the server, thus all the privileges applicable to PSM can be granted to Java classes.
The Java external procedure is included in the current transaction.
When a Java external procedure is called while the Tibero server is handling a client request, the JEPA process waits until the request is completed.
The Java external procedure is included in the current transaction, so it is possible to commit or roll back the transaction depending on the execution result.
Users can perform SQL operations on the current transaction using JDBC APIs.
Java external procedures are included in the current transaction, so users can perform query or DML operations on the current transaction using JDBC APIs.
To enable this feature, users can use the Internal JDBC Driver provided by Tibero. For detailed information about the internal JDBC driver, refer to “Internal JDBC Driver”.
Executing Java External Procedures
Java classes registered using the Java external procedure are dynamically loaded upon request for execution. This action is not performed by a server process, but by a JEPA process.
A JEPA process is automatically created when the Tibero server is started with the specified initialization parameter. Then the JEPA process receives the various information needed to call the Java class from the server process. They are the library class name, the function to call, the parameter information, and so on.
The JEPA process dynamically loads the shared library and searches for the function. Based on the user entered parameters, the JEPA process executes the function. When the function has a return value or output parameter, the JEPA process delivers the value to the server process.
These procedures are automatically processed in Tibero, thus users can write application programs in the same way as they write PSM functions.
The following figure illustrates how a Java external procedure is executed.
[Figure 2] Execution of a Java External Procedure
The Java external procedures are executed according to the following steps.
A JEPA process is created when a database server is started.
User registers a user Java class (Java source: .class) as an Java object in the database.
User writes a PSM program to map to the Java object.
The PSM program connects to the JEPA process to call a function. The program delivers the library information (such as class name, function name, parameter information and so on) to any of the tbEPA processes, and waits the processing result.
The JEPA process searches for the function to execute. Then it sends the result to the server.
The database server analyzes the result received from the JEPA process and sends it to the user.
The connection is established again when the PSM program is called after a session is made.
The JEPA process is automatically closed when the database server is closed.
Last updated