If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Calling Java Application from PL/SQL code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-07-04, 03:35
amk010 amk010 is offline
Registered User
 
Join Date: Jan 2004
Posts: 9
Question Calling Java Application from PL/SQL code

Colleagues,

I am not an expert in PL/SQL neither Java, so I require a help here:

What I am planning to do is to use PL/SQL to call a Java application (pass 3 arguments).

The Java application is used to make call to an API that resides on a Bea Weblogic application/web server (it’s not used to access database).

I got already the PL/SQL Trigger, but I need to add to it the call to the Java application (the Java application already exists)

Simply, would any one provide an example of how to make that call.

Do I need to load Java classes into the Oracle database or not…?

I am using Oracle 9i database, and the Java application is compiled using Java SDK 1.4.2

Many thanks…
Reply With Quote
  #2 (permalink)  
Old 01-07-04, 06:15
suneel.kumar suneel.kumar is offline
Registered User
 
Join Date: Jan 2004
Location: Hyderabad, India
Posts: 37
Hi,

To call java class from a pl/sql, you need to follow the steps.

1. First create a java file and compile it.

2. Load the java class file to the database using 'loadjava' utility.

Ex: loadjava -u scott/tiger abc.class

3. Create a pl/sql wrapper aroung the java class like

CREATE OR REPLACE PROCEDURE test (a1 VARCHAR2) AS LANGUAGE JAVA name 'abc.main(java.lang.String[])';

4. Then execute the stored procedure

exec test(<input>);
__________________
Regards
Suneel
Reply With Quote
  #3 (permalink)  
Old 01-07-04, 07:14
satish_ct satish_ct is offline
Registered User
 
Join Date: Nov 2003
Location: Bangalore, INDIA
Posts: 333
Thumbs up

HI,

Invoking the java stored procedures from any PL/SQL block or stored module works the same way it would for any other PL/SQL stored function.

For example:

SQLPLUS> set serveroutput on size 5000;

SQLPLUS> declare
2> temp varchar2(100);
3> begin
4> temp := ConcatTwo('Hello','World');
5> DBMS_OUTPUT.PUT_LINE(temp);
6> end;
7> /
__________________
SATHISH .
Reply With Quote
  #4 (permalink)  
Old 01-07-04, 23:36
amk010 amk010 is offline
Registered User
 
Join Date: Jan 2004
Posts: 9
Cool

Thanks... suneel.kumar and satish_ct

you realy give me some ideas...
Reply With Quote
  #5 (permalink)  
Old 01-08-04, 09:16
olerag olerag is offline
Registered User
 
Join Date: Aug 2003
Posts: 40
These examples provide the capability to load specific "classes" to the
database and most will work however Oracle will have problems with
classes that import from GUI packages such as AWT or Swing.
Reply With Quote
  #6 (permalink)  
Old 01-09-04, 07:03
satish_ct satish_ct is offline
Registered User
 
Join Date: Nov 2003
Location: Bangalore, INDIA
Posts: 333
Thumbs up

HI,

Did U come across any such error?
__________________
SATHISH .
Reply With Quote
  #7 (permalink)  
Old 01-09-04, 07:16
amk010 amk010 is offline
Registered User
 
Join Date: Jan 2004
Posts: 9
Smile

My class is only initiate a request or call to another system API (my class doesn't import from any GUI Packages).

Many thanks to you all
Reply With Quote
  #8 (permalink)  
Old 01-09-04, 07:57
amk010 amk010 is offline
Registered User
 
Join Date: Jan 2004
Posts: 9
Unhappy

when I've tried to load the java class, but I got the following error:

ORA-04031: unable to allocate 4032 bytes of shared memory ("shared pool","unknown object","joxs heap init","ioc_allocate_pal")

would some one told me what I should do.

I think that the shared pool is out of memory so should I consult the DBA, system Admin or is it from my PC, where I am making a conection to the server/Database.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On