Oracle calls Java external stored procedures

Source: Internet
Author: User
1. Compile Java2. use loadjava to import the database. loadjava-ult; usergt; lt; passwdgt; @ lt; tnsgt;-r under $ ORACLE_HOMEbin

1. Compile Java2. use loadjava to import the database. loadjava-u lt; usergt;/lt; passwdgt; @ lt; tnsgt;-r under $ ORACLE_HOME/bin

1. Write Java

2. Use loadjava to import the database. loadjava is under $ Oracle_HOME/bin.

Loadjava-u / @ -Resolve-v

This method loads sourcecode into the database.

If you have previously loaded the same java program, you must first drop

Dropjava-u / @ -V

3. Check that the java database has been imported

Select * from user_source where type LIKE 'java % 'and name =' '

4. Create a function

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

Appendix:

If you need java to access files, you must use the dba user to grant permissions.

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 ');


The statement for revoking permissions is as follows:

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 ');

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.