SQL/MX 3.2.1 Guide to Stored Procedures in Java (H06.26+, J06.15+)

Figure 1 Different Applications Calling the Same SPJ
For more information, see Chapter 5: Invoking SPJs in NonStop SQL/MX.
Common Packaging Technique
Different applications can invoke the same SPJ to perform a common business function. By
encapsulating business logic in an SPJ, you can maintain consistent database operations and avoid
duplicating code in applications.
Applications that call SPJs are not required to know the structure of the tables that the SPJ methods
access. If the table structure changes, you must change the SPJ methods but not necessarily the
CALL statements within each application.
Security
By using SPJs, you can conceal sensitive business logic inside SPJ methods instead of exposing it
in client applications. You can also grant privileges to execute an SPJ to specific users and restrict
the privileges of other users. For more information, see Granting Privileges for Invoking SPJs
(page 83).
Increased Productivity
Use SPJs to reduce the time and cost of developing and maintaining SQL/MX applications. By
having several applications call the same SPJ, you need only change the SPJ method once when
business rules or table structures change instead of changing every application that calls the SPJ.
Using the Java language to implement stored procedures increases development productivity.
Given the popularity of the Java language, you can leverage the existing skill set of Java
programmers to develop SPJs. The portability of the Java language enables you to write and
compile Java class files for SPJs once and deploy them anywhere.
Portability
Because SPJ methods are written in Java, and SPJs conform to the ANSI SQL standard, SPJs are
portable across different database servers. With minimal changes to SPJ methods, you can port
existing Java classes from another database server to a NonStop server and register the methods
as SPJs in NonStop SQL/MX. You can also port existing applications that call SPJs from other
databases to NonStop SQL/MX with minimal changes to the CALL statements in the application.
20 Introduction