2

My customer wants to be able to call a jar file from Oracle PL/SQL.

Java 1.6, Oracle 11g R2

How do I do this?

2 Answers 2

3

I did a bit of research into loadjava (the program that loads classes into Oracle). Sounded like a pain in the butt.

So I opted to run my jar outside Oracle but called from Oracle DBMS_SCHEDULER by PL/SQL.

Here's how:

BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name            => 'testjar',
program_type            => 'EXECUTABLE',
program_action          => 'C:\MYSTUFF\testjar.bat',
enabled                 => TRUE,
comments                => 'test testjar'
);
END;
/

begin  
dbms_scheduler.create_job  
 (job_name => 'testjar_job',  
  program_name=> 'testjar',    
  enabled=>true,  
  auto_drop=>false,  
  comments=>'Only run immediately by dbms_scheduler.run_job');  
end; 
/


begin  
    dbms_scheduler.run_job('testjar_job',TRUE);  
end;  
/
Sign up to request clarification or add additional context in comments.

1 Comment

I agree with you Hog..But I think that is not enough :)
0

After playing around I found out that the schema JAR_NAME.jar///ClassName.methodName(.... works.

So for example:

Function do()
return String
AS
      LANGUAGE java
         NAME 'my_jar.jar///MyClass.myMethod() return oracle.sql.String';

Note that it seems like some jar name files does not work. For example I had problems with a "-" in jar.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.