Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

File ZIp Using Java code

sanAug 17 2012 — edited Aug 17 2012
Dear All,

I am using the below code for zipping the file.
import java.util.zip.*;
import java.io.*;
import java.sql.*; 
public class UTLZip10
{
 public static void  COMPRESSFILE(String infilename, String outfilename)throws Exception{
  try{
       #sql { INSERT INTO ZIP_TEST (STAGE)
                          VALUES ('ENTERING') };
    FileOutputStream fout = new FileOutputStream("/apexrepdp/BROKERREPORTS/test.zip");

     ZipOutputStream zout = new ZipOutputStream(fout);
     ZipEntry ze = new ZipEntry((new File("/apexrepdp/BROKERREPORTS/test.csv")).getName());
     FileInputStream fin = new FileInputStream("/apexrepdp/BROKERREPORTS/test.csv");
        zout.putNextEntry(ze);
        copy(fin, zout);
        zout.closeEntry();
        fin.close();
        zout.close();
    }catch(Exception e){
	  System.out.println("IO Exception occurred: " + e);
     throw e;
    }
 }
  
 public static void copy(InputStream in, OutputStream out)throws Exception{ 
  byte[] buffer = new byte[4096];
  while (true) {
    int bytesRead = in.read(buffer);
    if (bytesRead == -1) break;
    out.write(buffer, 0, bytesRead);
  }
 }     
};
create or replace
PACKAGE               "SSSL_FILE_ZIP" 
IS
   procedure COMPRESSFILE (P_IN_FILE in varchar2, P_OUT_FILE in varchar2)
   AS
      LANGUAGE java
         NAME 'UTLZip10.COMPRESSFILE(java.lang.String,
                   java.lang.String)';
END;
when i create the class in Oracle 10.2.0.1.0 the code working fine.

I do the export from Oracle 10.2.0.1.0 and import into Oracle 10.2.0.4.0

when i execute the code in the new database i am getting the below error
Error report:
ORA-29532: Java call terminated by uncaught Java exception: java.io.FileNotFoundException: No such file or directory
ORA-06512: at "SMF_APEXRPS.SSSL_FILE_ZIP", line 3
ORA-06512: at line 4
29532. 00000 -  "Java call terminated by uncaught Java exception: %s"
*Cause:    A Java exception or error was signaled and could not be
           resolved by the Java code.
*Action:   Modify Java code, if this behavior is not intended.
But the file present in the oracle directory.

Why i am getting this error?? and how to resolve this ???

The code is working fine in Other DB.

Cheers,
San
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 14 2012
Added on Aug 17 2012
9 comments
652 views