ORA-29531: no method <string> in class <string> [message #411801] |
Mon, 06 July 2009 19:55 |
baekyasi
Messages: 4 Registered: July 2009 Location: Republic of Korea
|
Junior Member |
|
|
Hi,
I am trying to use Java Stored procedure for the first time.
Help me, please.
-------------------------------------
Loading java Source (DB ver. 10g)
-------------------------------------
package util;
import java.io.IOException;
import sun.misc.BASE64Encoder;
import java.security.MessageDigest;
import java.security.Key;
import java.security.InvalidKeyException;
import java.security.spec.InvalidKeySpecException;
import javax.crypto.Cipher;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.SecretKeyFactory;
public class UtilCryptoOuter {
private Key keyMulticampus = null;
private Cipher cipher = null;
private DESedeKeySpec kspec = null;
private SecretKeyFactory skf= null;
private String keyvalue = null;
public UtilCryptoOuter() {
try {
cipher = Cipher.getInstance("DESede");
skf= SecretKeyFactory.getInstance("DESede");
} catch (Exception e) {
System.out.println(e.toString());
}
}
//
public void setKey(String in) throws InvalidKeyException, InvalidKeySpecException{
keyvalue = in;
kspec = new DESedeKeySpec(keyvalue.getBytes());
keyMulticampus = skf.generateSecret(kspec);
}
//
public String encrypt3DES(String input)
throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
cipher.init(Cipher.ENCRYPT_MODE, keyMulticampus);
return ((new BASE64Encoder()).encode(cipher.doFinal(input.getBytes()))).replaceAll("\r\n","");
}
//
public String decrypt3DES(String input)
throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, IOException {
byte[] encryptionBytes = new sun.misc.BASE64Decoder().decodeBuffer(input);
cipher.init(Cipher.DECRYPT_MODE, keyMulticampus);
return new String(cipher.doFinal(encryptionBytes));
}
// TEST
public static void main(String args[]) throws Exception {
String strResult = null;
UtilCryptoOuter uco = new UtilCryptoOuter();
if (args[0].equals("Enc")) {
System.out.println("Encode : " + uco.encrypt3DES(args[1]));
}
else {
System.out.println("Decode : " + uco.decrypt3DES(args[1]));
}
}
}
-------------------------------------
Loading java Source Result
-------------------------------------
select *
from user_objects where object_type LIKE 'JAVA%' ;
==>
util/UtilCryptoOuter JAVA SOURCE VALID
util/UtilCryptoOuter JAVA CLASS VALID
-------------------------------------
Created function
-------------------------------------
CREATE OR REPLACE PACKAGE BODY common_bl_pkg IS
.....
FUNCTION encrypt3DES(param1 VARCHAR2) RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'util.UtilCryptoOuter.encrypt3DES(java.lang.String) return java.lang.String';
.....
END common_bl_pkg;
-------------------------------------
Execute
-------------------------------------
SELECT common_bl_pkg.encrypt3DES('A')
FROM dual;
==>
ORA-29531: no method encrypt3DES in class util/UtilCryptoOuter
|
|
|
|
|