Home  >  Article  >  Database  >  Oracle调用Java外部存储过程

Oracle调用Java外部存储过程

WBOY
WBOYOriginal
2016-06-07 17:00:341023browse

1. 编写Java2.使用loadjava导入数据库,loadjava在$ORACLE_HOME/bin下loadjava -u lt;usergt;/lt;passwdgt;@lt;tnsgt; -r

1. 编写Java

2.使用loadjava导入数据库,loadjava在$Oracle_HOME/bin下

loadjava -u /@  -resolve -v

这种方法为把sourcecode也load入数据库

如果之前已经有load过同一个java程序,需要先drop

dropjava -u /@ -v

3.核对java已经导入数据库

select * from user_source where type LIKE 'JAVA%' AND NAME = ''

4. 建立function

CREATE OR REPLACE FUNCTION () RETURN AS
   LANGUAGE JAVA
   NAME '() return java datatype of return variable';

附:

如果需要java存取文件,需要使用dba用户赋权

EXEC Dbms_Java.Grant_Permission('ONBOARDING', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC Dbms_Java.Grant_Permission('ONBOARDING', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
EXEC dbms_java.grant_permission( 'ONBOARDING', 'SYS:java.io.FilePermission', '>', 'execute' );


收回权限的语句如下

EXEC Dbms_Java.revoke_Permission('ONBOARDING', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC Dbms_Java.revoke_Permission('ONBOARDING', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
EXEC dbms_java.revoke_permission( 'ONBOARDING', 'SYS:java.io.FilePermission', '>', 'execute' );

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn