Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts
Tuesday, June 2, 2015
In this post, let us see how to execute a Java program from PLSQL or simply Oracle Database. I tried to explain in Step by Step Approach.
1. Create a Java Class and place it in the OS location of the server.
2. Load the Java class file into Oracle Database using loadjava utility
3. Prepare the wrapper PLSQL function to call the Java Class
4. Verify the Execution of the Java class from Oracle DB
Step1: Create a Java Class and place it in the OS location of the server.
public class Math{public static int Sum (int x, int y){return (x + y );}public static int difference (int x, int y ){return (x-y);}}
Step2: Load the Java class file into Oracle Database using loadjava utility
loadjava –user <db_username>/<db_password> <java Source file name>
We can verify the loaded objects from Database,
Step3: Prepare the wrapper PLSQL function to call the Java Class
CREATE OR REPLACE FUNCTION do_sum (x NUMBER, y NUMBER)-- Return type should match the return type of java member functionRETURN NUMBERASLANGUAGE JAVANAME 'Math.Sum(int,int) return int';/
4.Verify the Execution of the Java class from Oracle DB
Happy Sharing 
Tuesday, June 2, 2015 by Team search · 0
Subscribe to:
Posts (Atom)
Disclaimer
The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.