Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
I think by preload you really mean compile Java code as a stored procedure inside the database? Because when I look at the link you supplied that appears to be what is going on. Can you confirm this? – Chris Aldrich May 10 '12 at 12:51
Confirmed: the Java stored procedure depends on those two libraries. Locally they are in the classpath, so it compiles successfully. But when deploying on the server it fails, since it cannot resolve these dependencies at runtime. – Marius Butuc May 10 '12 at 13:40
Just curious if what was suggested below was helpful and if it worked. – Chris Aldrich Jun 4 '12 at 13:05

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.