Parameters in Java routines

Parameter declaration in Java™ routines must conform to the requirements of one of the supported parameter styles.

The following parameter styles are supported for Java routines:
  • PARAMETER STYLE JAVA
  • PARAMETER STYLE DB2GENERAL
  • PARAMETER STYLE HIVE

It is strongly recommended that you specify the PARAMETER STYLE JAVA clause in the routine CREATE statement. With PARAMETER STYLE JAVA, a routine uses a parameter passing convention that conforms to the Java language and SQLJ Routines specification.

The following list contains the Java routine features that cannot be implemented or used with PARAMETER STYLE JAVA:
  • Table functions
  • Scratchpads in functions
  • Access to the DBINFO structure in functions
  • The ability to make a FINAL CALL (and a separate first call) to a function or method
You can implement features that cannot be implemented or used with PARAMETER STYLE JAVA by creating your routine in C, or parameter style DB2GENERAL.

If you migrate your user-defined function (UDF) from Hive, specify PARAMETER STYLE HIVE in the CREATE statement to reduce the need to rewrite your routine implementation. By using PARAMETER STYLE HIVE, a routine can use the parameter passing convention that conforms to the Apache Hive mechanism for invoking UDFs. The Apache Hive mechanism extends the org.apache.hadoop.hive.ql.exec.UDF class.

The following classes are always in the CLASSPATH for PARAMETER STYLE HIVE functions. You can reference them by the implementation of those functions without deploying the CLASS or JAR files under the database function directory:
  • org.apache.hadoop.io.*
  • org.apache.hadoop.hive.ql.*
When you compile a Java class to use as a PARAMETER STYLE HIVE UDF, include the following JAR files in the CLASSPATH:
  • All of the JAR files in $HIVE_HOME/lib
  • $HADOOP_HOME/hadoop-core.jar
The following routine features cannot be implemented with PARAMETER STYLE HIVE:
  • Table functions
  • Scratchpads in functions
  • Access to the DBINFO structure in functions
  • The ability to make a FINAL CALL (and a separate first call) to a function or method
  • READS SQL DATA or CONTAINS SQL
  • EXTERNAL ACTION
  • NOT DETERMINISTIC
  • DISALLOW PARALLEL