While the referenced question is similar it speaks to putting the source code into the database not the class, also I would like to use the TOAD utilities to accomplish this.
So as proof of concept I have been attempting to load a java class into an Oracle 12c Database and access it via an Oracle function.
I opened Eclipse and created new project Hello with class Hello:
public class Hello {
public static String world()
{
return "Hello world";
}
}
I compiled it and now on my client I have
C:\Users\me\workspaces\Hello\bin\Hello.class
I opened up TOAD for an oracle 12c database, then I went to utilities / Java Manager and loaded my class:
TOAD says it successfully loaded. However, I'm not sure if it did.
Next, I went into the TOAD editor and created a function:
CREATE OR REPLACE function "DIR\KBD0010".helloworld RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'Hello.world () return java.lang.string';
Then I attempted to select it with a sql query:
select helloworld()
from dual;
And then I am getting:
ORA-29540: class Hello does not exist