Db2 – Preloading a Java library in DB2, similar to ORACLE’s loadjava

db2javaoraclestored-procedures

Edit to add details to clarify, based on Chris' comment:

A Java stored procedure depends on external libraries. Locally it compiles successfully, since they are added to the classpath. But when deploying on the server it fails, since it cannot resolve these dependencies at runtime.


Does DB2 have any functionality to automatically preload a library / Java stored procedure?
I'm looking for something similar to ORACLE's loadjava:

loadjava -u myuser/MYPW -resolve mail-1.4.3.jar
loadjava -u myuser/MYPW -resolve aws-java-sdk-1.3.8.jar

Best Answer

Ok, what I believe you are after is creating Java routines (ie, stored procedures implemented in Java and stored within DB2).

You will want to follow the documentation in this section on Java routines. Pay special attention to the Creating, Building, and Deploying sections.

And even though this is an older article, you may wish to check out this article "Solve common problems with DB2 UDB Java stored procedures" on developerworks. It also discusses the when/where of using Java routines in DB2, how you go about creating them, and common problems encountered.