Using Java to implement DB2 custom functions

xiaoxiao2021-03-06  41

We know that the functions provided in DB2 are limited. This problem is encountered in the actual work of the author. So we need to define your function in the project used in DB2. Fortunately, the DB2 also provides custom functions. Function. The following author will use Java to implement the DB2 custom function, first write the Java implementation code import com.ibm.db2.app. *;

Public Class DB2UDF EXTENDS UDF {

/ ** * * / public db2udf () {} / ** * Return two values ​​in bit and operation results * @Param Num1 * @Param Num2 * @return Int * / Public Static int Bitand (int Num1, int Num2 ) {RETURN NUM1 & NUM2;}}

Compiled, the place to pay attention to is to be compiled with the JDK comes with DB2. Then put this Class file in the DB2 installation path / SQLLIB / FUNCTION

And then to declare the DB2 client-defined functions can be used - two plastic figures by bit and drop function bitand; create function bitand (value1 int, value2 int) returns integerfencedvariantno sqllanguage javaparameter style javaexternal name 'DB2Udf! Bitand ';

转载请注明原文地址:https://www.9cbs.com/read-112692.html

New Post(0)