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

public static void main (java.lang.String [] args) {
...
}
When you register a main() method as an SPJ, you can specify zero or more SQL parameters,
even though the underlying main() method has only one array parameter. All the SQL
parameters of the SPJ must have the character string data type, CHAR or VARCHAR, and be
declared with the IN mode.
If you specify the optional Java signature, the signature must be (java.lang.String []).
For more information about registering an SPJ, see Chapter 5 (page 43).
Null Input and Output
You can pass a null value as input to or output from an SPJ method, provided that the Java data
type of the parameter supports nulls. Java primitive data types do not support nulls. However,
Java wrapper classes that correspond to primitive data types do support nulls. If a null is input
or output for a parameter that does not support nulls, Neoview SQL raises an error condition.
To anticipate null input or output for your SPJ, use Java wrapper classes instead of primitive
data types in the method signature.
For example, this Java method uses a Java primitive data type in its signature where no null
values are expected:
public static void employeeJob(int empNum,
Integer[] jobCode)
This Java method also uses a Java wrapper class in its signature to anticipate a possible returned
null value:
public static void employeeJob(int empNum,
Integer[] jobCode)
Static Java Variables
To ensure that your SPJ method is portable, you should avoid using static variables in the method.
Neoview SQL does not ensure the scope and persistence of static Java variables.
Nested Java Method Invocations
An SPJ that invokes another SPJ by issuing a CALL statement causes additional system resources
to be used. If you want an SPJ method to call another SPJ method, consider invoking the other
Java method directly through Java instead of using a CALL statement. The other Java method
should be packaged in the same JAR file as the SPJ method. For more information, see “Compiling
and Packaging Java Classes” (page 32).
Accessing a Neoview Database
SPJ methods that access a Neoview database must be from a Java class that uses JDBC method
calls. Follow these guidelines when writing an SPJ method that accesses a Neoview database:
“Use of java.sql.Connection Objects” (page 29)
“Using JDBC Method Calls” (page 30)
“Referring to Database Objects in an SPJ Method” (page 31)
“Exception Handling” (page 32)
Use of java.sql.Connection Objects
Neoview SQL supports a default connection in an SPJ execution environment, which has a data
source URL of "jdbc:default:connection". For example:
Connection conn = DriverManager.getConnection("jdbc:default:connection");
Accessing a Neoview Database 29