Back to Browse

| Invoking Java Program in PLSQL | Executing Java program in Oracle | PLSQL Wrapper method |

6.3K views
Premiered Dec 28, 2019
9:55

Please Subscribe My channel and don't forget to hit the bell icon to get the latest updartes. Scripts are given below ----------------------------------------- How to Execute a Java Program in Oracle ----------------------------------------- Prerequisite -------------- (1) JDK (2) ORACLE DATABASE (3) Basic Knowledge on Java Step-1 ------ - First we need to create a Java Program (Main Function will Not included) - Program should be saved with the classname with extension as java (i.e Square_Cube.java) Example-1: ----------- public class Square_Cube{ public static int Square (int a){ return a * a; } public static int Cube(int b){ return b * b * b; } } Step-2 -------- - Compile the Java Program to generate Class file from the Java file javac Square_Cube.java Step-3 ------- - Once the class file generated , we need to perform below task - Connect to System/Sys user and Grant the below previliges GRANT JAVAUSERPRIV TO HR; Step-4 ------- - Load the class on the server using the loadjava tool. You must specify the user name and password loadjava -thin -user hr/hr@localhost:1521:orcle -resolve -verbose "E:\Java_Program_Area\Square_Cube.java" Step-5 ------- - CREATE A FUNCTION IN ORACLE DATABASE CREATE OR REPLACE FUNCTION square ( a NUMBER ) RETURN NUMBER AS LANGUAGE JAVA NAME 'Square_Cube.Square(int) return int'; CREATE OR REPLACE FUNCTION cube ( a NUMBER ) RETURN NUMBER AS LANGUAGE JAVA NAME 'Square_Cube.Cube(int) return int'; NOTE: Java is a Case Sensitive Language so check the keyword (like 'return','int') Step-6 ------- - Lets execute the function using SELECT statement SELECT SQUARE(5),CUBE(5) FROM DUAL; LIKE THE FACEBOOK PAGE - https://www.facebook.com/Oracle-Tutorials-108483330680405/ FOLLOW ON Instagram - https://www.instagram.com/nihar8308/ FOLLOW ON LinkedIn - https://www.linkedin.com/company/oracle-tutorials/?viewAsMember=true FOLLOW ON TWITTER - https://twitter.com/NIHARRA59094760 Email Id: [email protected] Phone No- 8018319781 #Calling_Java_Program #Oracle_SQL_PLSQL_Concept #Invoke_Java_Program #Java_Program_in_Oracle

Download

0 formats

No download links available.

| Invoking Java Program in PLSQL | Executing Java program in Oracle | PLSQL Wrapper method | | NatokHD