Differences between Java routines and stand-alone Java programs
Java routines differ in a few basic ways from stand-alone Java programs.
Those differences are:
- 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.
- 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
- 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.