Neoview Guide to Stored Procedures in Java (R2.2)

3 Developing SPJ Methods
Before creating, or registering, an SPJ in a Neoview database, you must write and compile the
Java method to be used as the body of the SPJ. The manual refers to those Java methods as SPJ
methods.
This chapter requires a familiarity with writing and compiling Java programs and covers these
topics:
“Guidelines for Writing SPJ Methods”
Accessing a Neoview Database” (page 29)
“Handling Java Exceptions” (page 32)
“Compiling and Packaging Java Classes” (page 32)
Guidelines for Writing SPJ Methods
Follow the guidelines for these topics when you write SPJ methods to be used as SPJs in a Neoview
database:
“Signature of the Java Method”
“Returning Output Values From the Java Method” (page 26)
“Returning Stored Procedure Result Sets” (page 27)
“Using the main() Method” (page 28)
“Null Input and Output” (page 29)
“Static Java Variables” (page 29)
“Nested Java Method Invocations” (page 29)
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,
Neoview SQL is unable to find the Java method when you try to register the SPJ 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.
Java Parameters
Except for result sets, which are described in “Returning Stored Procedure Result Sets” (page 27),
the parameter types in the Java signature must correspond to the SQL parameters of the stored
procedure that you are planning to create. For type mappings, see Table 3-1.
Guidelines for Writing SPJ Methods 25