DBMS_RUNJAVA doesn't find my class

758 views Asked by At

I would like to run a java program on my oracle server 12C. I tried that but it's not working :

CREATE OR REPLACE JAVA SOURCE NAMED "HELLO" AS
public class Hello {
      public static void main(String[] args){
        System.out.println("succeed");
      }
}
;

SELECT dbms_java.runjava('-cp jserver:/CP/SHARED_DATA/PRIVATE/SCHEMA/LLAMARCHE/ Hello')  FROM DUAL;

This returns :

ORA-29532: Java call terminated by uncaught Java exception: java.lang.ClassNotFoundException: Hello

Thanks......

1

There are 1 answers

1
Aramillo On BEST ANSWER

You can also do this by other way:

First, create the java class.

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Hello" AS
import java.io.*;
public class Hello {
public static void executeCommand() {
    System.out.println("succeed");
}
};
/

Later, create an oracle procedure that invoke this class, like this.

CREATE OR REPLACE procedure CallHello
AS LANGUAGE JAVA
NAME 'Hello.executeCommand ()';

And finally, make the call from the editor.

begin
CallHello;
end;

I hope this helps.