EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #192 background imageLoading...
Page #192 background image
Differences between Java routines and stand-alone Java
programs
There are a few basic difference between Java routines and stand-alone Java
programs.
Those differences are:
v In a Java routine, a JDBC connection or an SQLJ connection context can use the
connection to the data source that processes the CALL statement or the
user-defined function invocation. The URL that identifies this default connection
is jdbc:default:connection.
v The top-level method for a Java routine must be declared as static and public.
Although you can use static and final variables in a Java routine without
problems, you might encounter problems when you use static and non-final
variables. You cannot guarantee that a static and non-final variable retains its
value in the following circumstances:
Across multiple invocations of the same routine
Across invocations of different routines that reference that variable
v As in routines in other languages, the SQL statements that you can execute in
the routine depend on whether you specify an SQL access level of CONTAINS
SQL, READS SQL DATA, or MODIFIES SQL DATA.
Related concepts
“Differences between Java routines and other routines”
Related reference
SQL statements allowed in external functions and stored procedures (DB2
SQL Reference)
Differences between Java routines and other routines
There are a few basic difference between Java routines and routines in other
programming languages.
A Java routine differs from stored procedures that are written in other languages in
the following ways:
v A Java routine must be defined with PARAMETER STYLE JAVA. PARAMETER
STYLE JAVA specifies that the routine uses a parameter-passing convention that
conforms to the Java language and SQLJ specifications. DB2 passes INOUT and
OUT parameters as single-entry arrays. This means that in your Java routine,
you must declare OUT or INOUT parameters as arrays. For example, suppose
that stored procedure sp_one_out has one output parameter of type int. You
declare the parameter like this:
public static void routine_one_out (int[] out_parm)
v Java routines that are Java main methods have these restrictions:
The method must have a signature of String[]. It must be possible to map all
the parameters to Java variables of type java.lang.String.
The routine can have only IN parameters.
v You cannot make instrumentation facility interface (IFI) calls in Java routines.
v You cannot specify an SQL access level of NO SQL for Java routines.
v As in other Java programs, you cannot include the following statements in a
Java routine:
CONNECT
RELEASE
176 Application Programming Guide and Reference for Java
|

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability