问题
I've a function in Java that uses an external library (jackson) to work with JSON structures. How can I include my function and all its dependencies in Oracle(12c) PL\SQL? The DB host is an unix os.
回答1:
You need to compile your project as fat jar. It means a jar that includes its dependencies on it. Using with zip opener, you can open a fatjar and find jar dependencies in parent fatjar.
After you create your project on unix os which your db runs on go to jar path and run the code below
$ > loadjava -user userName/password@dbName FirstFatJar.jar
Now you uploaded your jar to oracle. And assume that you have a java class in jar that name is Master and it has a function that name is Atesle which returns java.lang.String. Than connect your oracle db and create java stored procedure/function like that
CREATE or replace FUNCTION atesle1 RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'Master.atesle() return java.lang.String';
Now you can run your java code via oracle store procedure with code below;
select atesle1() from dual
来源:https://stackoverflow.com/questions/43782772/how-to-include-java-functionsand-external-libraries-too-in-oracle-pl-sql