rami.info



Calling JAVA code from Oracle

Posted in RDBMS,Software,TechNotes by Rami on the March 19th, 2006

To run java code from oracle do the following:

1. Create the java code on the server:

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "hello" AS
public class hello {
public static String world() {
return "Hello World";
}
}
/

2. Create the oracle function on the server:

CREATE OR REPLACE FUNCTION hellofunction RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'hello.world() return java.lang.String';
/

3. Call the function using a SELECT:

SELECT hellofunction() from DUAL;

7 Responses to 'Calling JAVA code from Oracle'

Subscribe to comments with RSS or TrackBack to 'Calling JAVA code from Oracle'.

  1. Mark said,

    on March 19th, 2006 at 5:20 pm

    /kick #rami.info rami
    /ban rami

  2. Jackie said,

    on March 19th, 2006 at 9:53 pm

    I second Mark, I mean I am getting nothing from here other than those weird thingys :/

  3. Rami said,

    on March 20th, 2006 at 9:04 am

    Oh comeon guys! If I don’t post stuff like that then where else would you get this information from? :) Plus that’s better than posting nude pictures like some people do ;)

  4. Pearls said,

    on March 20th, 2006 at 1:52 pm

    lol.

  5. Azizsyr said,

    on March 24th, 2006 at 9:38 am

    it’s a good informaion , you should make some fees over it ;)_

  6. dotone said,

    on May 9th, 2006 at 12:01 am

    Too geeky for them rami ;)

    You could run PHP code from PostgreSQL as well. And in MSSQL server 2005, you could run .Net code (any registered language in the framework) too ;)

    I don’t think this feature would be cool to use unless you’re on heavly load transaction and PL/SQL based data transfer and queries that melt servers, other than that, triggers are enought to return some procedure call values.

  7. Bana said,

    on May 11th, 2006 at 5:33 pm

    Hehehe! As I was goin’ through the blog Rami, I thought, this guy can make xtra bucks tutoring people – think of that! You get the info, Pearls do translation when required (besides backing her hubby) and I will handle marketing your “commercial name” , how ‘bout that ?!

Leave a Reply