I would like to know if it is possible to call a Java class within the Oracle database.
I have already installed the JVM inside the Oracle server, but I can not compile the Java class.
Does anyone know of any way I can do this?
I would like to know if it is possible to call a Java class within the Oracle database.
I have already installed the JVM inside the Oracle server, but I can not compile the Java class.
Does anyone know of any way I can do this?
Yes, you can call Java code within the Oracle database. Here's a link to official documentation: link .
See Oracle example, you should follow these steps:
Defining a java class:
public class Hello
{
public static String world()
{
return "Hello world";
}
}
Compile the class normally using a JDK:
javac Hello.java
Open the compiled java class inside the bank:
loadjava -user MEUUSER Hello.class
Create the call to the Java method:
CREATE OR REPLACE FUNCTION helloworld RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'Hello.world () return java.lang.String';
/
You can consume the Java function directly from PL / SQL as an example of Oracle:
VARIABLE myString VARCHAR2(20);
CALL helloworld() INTO :myString;
PRINT myString;
However, as utluiz's comment , please that consuming a Java class directly from Oracle is not always the best architectural decision. It is often best to expose a Web Service and consume it through the bank. This can be done, for example, with the UTL_HTTP
package.