Recently I have worked on a project that I assume could be solved by using Java stored procedure (more precisely some recieving/sending email package).

Аfter a while I've found that there are very few number of Java classes and Java stored procedures in my company's database. I asked DBA and he said that using Java stored procedures is prohibited because "It can easily put the server down".

I would be greateful if someone could expain me: is it really dangerous to use Java stored procedures that use external packages? Are there any pitfalls? Is using Java stored procedures not a common practice?

  • 1
    Whether or not the use is "common" would depend on the organization. It's pretty rare in my databases, but I understand it is "common" at other locations. I believe that a well-run shop will standardize on a very few languages with firm rules on what is used for what kind of tasks. Then they hire for expertise in those languages. If someone happens to have expertise in a different language, it would not be beneficial to the organization to give that person free reign to use the language of his choice if no one else could step in in his absence. – EdStevens Mar 9 '19 at 21:16

A well-written Java stored procedure is unlikely to "put the server down", however, Java routines might have some performance implications, because invoking them means that Oracle needs to start a Java virtual machine (JVM) process, transfer control to it, and wait for the Java code to terminate. Since this is still happening within the scope of a SQL transaction, concurrency might suffer. This is especially true when Java is used to synchronously perform some potentially long running activities that depend on remote resources, such as sending and receiving email.

You probably want to avoid using Java stored procedure if possible; consider using the UTL_MAIL Oracle built-in package to handle email messages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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