Neoview Guide to Stored Procedures in Java (R2.2)
Table 3-1 Mapping of Java Data Types to SQL Data Types
Maps to SQL Data Type...Java Data Type
CHAR[ACTER]
CHAR[ACTER] VARYING
VARCHAR
PIC[TURE] X
1
NCHAR
NCHAR VARYING
NATIONAL CHAR[ACTER]
NATIONAL CHAR[ACTER] VARYING
java.lang.String
DATE
java.sql.Date
TIME
java.sql.Time
TIMESTAMP
java.sql.Timestamp
NUMERIC
DEC[IMAL]
PIC[TURE] S9
2
java.math.BigDecimal
SMALLINT
short
INT[EGER]
int or java.lang.Integer
3
LARGEINT
long or java.lang.Long
3
FLOAT
double or java.lang.Double
3
REAL
float or java.lang.Float
3
DOUBLE PRECISION
double or java.lang.Double
3
None
java.sql.ResultSet[]
1 Neoview SQL stores PIC X as a CHAR data type.
2 Neoview SQL stores PIC S9 as a DECIMAL or NUMERIC data type.
3 Choose a Java wrapper class if you plan to pass null values as arguments to or from the method. See “Null Input
and Output” (page 29).
Output parameters in the Java signature must be arrays (for example, int[] or String[]) that
accept only one value in the first element of the array at index 0. For more information, see
“Returning Output Values From the Java Method.”.
Returning Output Values From the Java Method
The Java method can return data to the calling application in the form of output parameters or
result sets. Output parameters in the Java signature are parameter arrays that accept one value
in the first element of the array at index 0. Result sets in the Java signature are one-element
java.sql.ResultSet[] arrays that contain ResultSet objects that have multiple rows of
data. For more information about result sets, see “Returning Stored Procedure Result Sets”
(page 27).This subsection covers these topics related to output parameters:
• “Using Arrays for Output Parameters” (page 26)
• “Type Mapping of Output Parameters” (page 27)
Using Arrays for Output Parameters
You must use arrays for the output parameters of a Java method because of how Java handles
the arguments of a method. Java supports arguments that are passed by value to a method and
does not support arguments that are passed by reference. As a result, Java primitive types can
26 Developing SPJ Methods