1

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:

Screenshot from TOAD

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
tent
  • 69
  • 8
Bryan Dellinger
  • 4,724
  • 7
  • 33
  • 79
  • Possible duplicate of [Calling Java from PL/SQL](http://stackoverflow.com/questions/18585546/calling-java-from-pl-sql) – Vijay Jun 14 '16 at 12:26
  • @Vijay Not a complete duplicate as the OP has loaded the java class into the database using toad - which appears to use Oracle's `loadjava` utility in the background (or at the very least has an uncanny similarity in the options and fields it takes as parameters). This question is more "having done the equivalent of the steps in that linked question why is it still not working?" – MT0 Jun 14 '16 at 13:06
  • The `resolve` option is used to compile the source into byte code - you have already done that as you are loading a `.class` file so you should not need to select that option. Also, if you have tried it and then try reloading it a second time you will need to check the `force` option to reload the file - if you do not then Oracle will ignore the upload. – MT0 Jun 14 '16 at 13:13
  • turned off the resolve checkbox and turned on the force option but still no luck. – Bryan Dellinger Jun 14 '16 at 15:17

0 Answers0