Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java code in Oracle database 11g

OraDev16Jan 17 2017 — edited Jan 17 2017

Dear All,

Prelude :

-----------

(1) jdk version : jdk1.5.0_22 (Using this version of jdk to make the java code in sync with Oracle DB 11g; as 11g uses jdk 1,5)

(2) Oracle Database : 11.2.0.1.0

Scenario :

-------------

(1) I've the following Java code (without main method).

public class Hello

{

  public static String world()

  {

    return "Hello world";

  }

}

(2) I complied it and got the class file.

(3) Loaded the class on the server using loadjava.

(4) Created the following function in SQL Developer.

CREATE OR REPLACE FUNCTION helloworld RETURN VARCHAR2 AS

LANGUAGE JAVA NAME 'Hello.world () return java.lang.String';

(5) Ran the following three statements.

VARIABLE myString VARCHAR2(20);

CALL HELLOWORLD() INTO :MYSTRING;

PRINT myString;

ISSUE :

----------

(6) Got blank output.

MYSTRING

---------------

Please, suggest me the missing link.

Thank you.

This post has been answered by JohnWatson2 on Jan 17 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 14 2017
Added on Jan 17 2017
3 comments
419 views