Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Calling java Classes

Re: Calling java Classes

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 03 Jan 2000 20:35:33 -0500
Message-ID: <nhj27s8aqp295ri3qpm1ufkvn2325k31qb@4ax.com>


A copy of this was sent to Entity Relationship Tools <apalvanchaNOapSPAM_at_yahoo.com.invalid>
(if that email address didn't require changing) On Mon, 03 Jan 2000 17:55:11 +1600, you wrote:

>Hi All,
>
>Does Oracle supports calling Java Classes? I would like to
>call a Java Class file from the Oracle Database Trigger
>PL/SQL Program. Could You please help me out in providing a
>solution.
>

Yes, in Oracle8i release 8.1 and up. Here is a small example of what it looks like:

C:\WINNT\Profiles\tkyte\Desktop\test>sqlplus tkyte/tkyte

SQL*Plus: Release 8.1.5.0.0 - Production on Fri Dec 31 09:43:47 1999

(c) Copyright 1999 Oracle Corporation. All rights reserved.

Connected to:
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production

tkyte_at_ORACLE> @a
tkyte_at_ORACLE>
tkyte_at_ORACLE> host "C:\Program Files\Oracle\JDeveloper 3.0\java\bin\javac"
Hello.java

tkyte_at_ORACLE>
tkyte_at_ORACLE> host loadjava -user tkyte/tkyte Hello.class

tkyte_at_ORACLE>
tkyte_at_ORACLE> host type Hello.java
import java.lang.*;
import java.lang.Throwable;

class Hello {
static public String World()
{

        return "Hello World";
}
}

tkyte_at_ORACLE>
tkyte_at_ORACLE> create or replace function HELLOWORLD return   2 varchar2 as
  3 language java name 'Hello.World() return   4 java.lang.string';
  5 /

Function created.

tkyte_at_ORACLE>
tkyte_at_ORACLE> variable myString varchar2(25);
tkyte_at_ORACLE> call HelloWorld() into :myString
  2 /

Call completed.

tkyte_at_ORACLE>
tkyte_at_ORACLE> print myString

MYSTRING



Hello World

tkyte_at_ORACLE>

>Thanks in Advance
>Avinash
>
>
>* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Mon Jan 03 2000 - 19:35:33 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US