SQL/MX Guide to Stored Procedures in Java (G06.24+, H06.03+)

HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
3-1
3 Writing SPJ Methods
Before you can create an SPJ in NonStop SQL/MX, you must write and compile the
Java method to be used as the body of the SPJ. The Java methods that you use for
the body of an SPJ are called SPJ methods.
This section requires a familiarity with writing and compiling Java programs and covers
these topics:
Guidelines for Writing SPJ Methods on page 3-1
Accessing SQL/MP and SQL/MX Databases on page 3-5
Accessing Enscribe Databases on page 3-10
Using Native Methods on page 3-10
Handling Java Exceptions on page 3-10
Writing Data to a File or Terminal on page 3-11
Compiling Java Classes on page 3-13
Guidelines for Writing SPJ Methods
Follow these guidelines when you write SPJ methods to be used as SPJs in NonStop
SQL/MX:
Signature of the Java Method on page 3-1
Returning Output Values From the Java Method on page 3-2
Using the main() Method on page 3-4
Null Input and Output on page 3-4
Static Java Variables on page 3-5
Nested Java Method Invocations on page 3-5
Signature of the Java Method
A Java method that you use as an SPJ must have this general signature:
public static void myMethodName (java-parameter-list)
Public Access and Static Modifiers
The Java method must be defined as public and static. If a method is private or
protected, NonStop SQL/MX is unable to find the Java method specified by the
CREATE PROCEDURE statement and returns an error. The Java method must be
defined as static so that the method can be invoked without having to instantiate its
class.
Void Return Type
The return type of the Java method must be void. The method must not return a value
directly to the caller.