Search Again:

Re: Uage of Java component from Oracle !!

From: Fabien Sanglard
Date: Friday, April 2, 2004
Time: 7:31:49 am

Hi,

I think that from your trigger, you can call a stored procedure (this SP,
can call a java function) such as following exemple:
I used it to make a MD5 encryption in Oracla 9i.

But, why are you using Java, maybe you can process within an Oracle Stored
procedure...?


CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "MD5Encoder" AS
import java.security.*;
import java.lan.*;

public class MD5Encoder {

private static String toHex(byte[] digest) {

String buf = "";
for (int i = 0; i < digest.length; i++) {

String token="";
token = Integer.toHexString(digest[i]);
if (token.length() == 1)
token = "0"+token;
token= token.substring(token.length()-2);
buf= buf+token;
}
return buf;

}

public static String encode(String in) {
try {
String out = "";
MessageDigest md = MessageDigest.getInstance("MD5");

byte[] rawPass = in.getBytes();
try {
md.update(rawPass);
} catch (Exception e) {}
out = toHex(md.digest());
return out;
} catch (NoSuchAlgorithmException nsae) {return "";}

}
};
/
CREATE OR REPLACE FUNCTION MD5 (param1 IN VARCHAR2) RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'MD5Encoder.encode (java.lang.String) return java.lang.String';
/
COMMIT;
/


----- Original Message -----
From: "Swapan Banerjee" <swaps_99@yahoo.com>
To: <oracle-list@digitalpoint.com>
Sent: Friday, April 02, 2004 4:31 PM
Subject: [Oracle] Uage of Java component from Oracle !!


> >
> >Hi,
> >
> >I have a typical situation where I need to use a Java
> component from a =
> >Oracle database Trigger (Insert).=20
> >
> >The Oracle database is under Windows env. The Java
> component is expected
> =
> >to fetch some matching records from a DB2 database
> which is in AS/400, =
> >based on the value of a column that is going to get
> inserted in the =
> >Oracle database table.
> >
> >The concerns are:
> >1. How to use / call such a Java component from a
> Oracle database =
> >trigger?
> >2. Will the Java component be able to fetch such
> records from another =
> >env like AS/400 and that too from another database
> like DB2?
> >3, What could be a probable solution for such a
> situation?
> >
> >Kindly help !!
> >Please send your reply to swaps_99@yahoo.com too !!
> >
> >Swaps.
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway
> http://promotions.yahoo.com/design_giveaway/
>
> ----------------------------------------------------------
> To subscribe, unsubscribe or to search list archive
> please visit http://www.digitalpoint.com/lists/oracle.html
> ----------------------------------------------------------
>


----------------------------------------------------------
To subscribe, unsubscribe or to search list archive
please visit http://www.digitalpoint.com/lists/oracle.html
----------------------------------------------------------



Messages In This Thread:



Return to Digital Point Solutions' Home Page