Use Oracle to call the Java class and load the jar package to Oracle to support the Java class.

Source: Internet
Author: User

According to the ghost sub-requirements, the original use of Oracle alone to send and receive mail was abandoned (the previous article described the specific implementation), instead of using Oracle to call Java, and use javamail to implement the relevant procedures of mail. This problem occurs. I have written Java and PL/SQL, but I have never heard of using Oracle to call Java. None of my colleagues have done so. However, I checked the relevant information to know that this technology does. Therefore, make the following related records.

 

The first thing I need to do is to load a previously compiled Java class with the compression function and the jar package files it needs into Oracle and make them successfully called. How to compress the file and process it later. Let's talk about how to load the Java class and jar package to Oracle.

 

First, the Environment configuration required for the compression function:

1. The operating system must have JDK that supports loadjava commands.

2. Load the jlha. jar package to the Oracle database.

Operation Process: in the DOS environment, enter the command: loadjava-r-f-o-user usscares/usscares @ usscares jlha. Jar

This is the command for Oracle to load the jlha. jar package.

Compile the required compression class: directoryzip

Insert a row in the header of the source file: Create or replace and compile Java source named directoryzip

Run the command window of the database to import the database.

Since the class has been successfully imported to Oracle, the next step is to compile the function so that Oracle can call the code in this class:

Create or replace function zipblob (returnBLob BLOB, inBlob BLOB, filename VARCHAR2) return BLOB as language java name 'jp.co.uss.cares.common.directoryzip.zip (oracle. SQL. BLOB, oracle. SQL. BLOB, java. lang. string) return oracle. SQL. BLOB ';/
 
Then you can write a test program and test it on the oralce console:
DeclarepBlob; -- original data rBlob; -- compressed data typrow uss_row; beginselect d0030 into pBlob from dewey. cysct0291 where d0020 = '000000'; rBlob: = empty_blob (); delete from dewey. cysct0291 where d0010 = 'tst'; insert into dewey. cysct0291 values ('tst', '000000', rBlob, ''); select d0030 into rBlob from dewey. cysct0291 where d0010 = 'tst' for update; -- rBlob: = comment '); rBlob: = zipListToBlob (rBLob, '1, 2, 3, 4, 54' | chr (13) | chr (10) | ',, '2008062520.6.csv '); commit; end;

Related Article

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.