Home » Developer & Programmer » Reports & Discoverer » Bad Images Cause Report to Crash (Oracle Reports Developer 10.1.2.3.0)
Bad Images Cause Report to Crash [message #594245] Mon, 26 August 2013 09:52 Go to next message
wtolentino
Messages: 390
Registered: March 2005
Senior Member
We have a report that is using a blob and in that blob is a text string that is in base64. The text string is converted into an image via a function that is a java class. The function works well when executed from SQL Developer, PL/SQL Developer, and other tools either good or bad image.

The problem is that in the reports it crash if the image is bad (no error message). In the report how do I make an exemption if the image is bad to just return null? This way the report does not crash. Thanks.
  • Attachment: ImageItem.jpg
    (Size: 97.91KB, Downloaded 1508 times)

[Updated on: Mon, 26 August 2013 09:58]

Report message to a moderator

Re: Bad Images Cause Report to Crash [message #594251 is a reply to message #594245] Mon, 26 August 2013 13:51 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
How do you know that an image is "bad"? (What does "bad" mean?)

I'd say that function should take care about it; if it detects a "bad" image, it should return NULL (or predefined "bad image" image, or something else but valid, that doesn't result in report crash).
Re: Bad Images Cause Report to Crash [message #594255 is a reply to message #594251] Mon, 26 August 2013 15:39 Go to previous messageGo to next message
wtolentino
Messages: 390
Registered: March 2005
Senior Member
We know that that if the image is bad the function returns unreadable strings rather than an image. This is how the oracle function in java class works. The function accepts paramerter in clob, this clob contains base64 text string. The function converts the base64 text string into an image. If the function returns an image that tells us it is a good image otherwise the function returns unreadable strings.

By looking at the base64 text string we can't tell if that will convert to a good or bad image. Thanks.

Below is the java class code:
create or replace function f_sims_base64_decode (myclob in clob) return blob
as language java
name 'Base64.decode(oracle.sql.CLOB) return oracle.sql.BLOB';

import java.sql.*;
import java.io.*;
import oracle.sql.*;
import sun.misc.BASE64Decoder;
import oracle.jdbc.driver.*;

public class Base64 {

public static oracle.sql.BLOB decode(oracle.sql.CLOB  myBase64EncodedClob)
  {

    BASE64Decoder base64   = new BASE64Decoder();
    OutputStream  outstrm  = null;
    oracle.sql.BLOB myBlob = null;
    ByteArrayInputStream instrm = null;
    
    try  
    {
      if (!myBase64EncodedClob.equals("Null"))
      {
        Connection conn = new OracleDriver().defaultConnection();
        myBlob = oracle.sql.BLOB.createTemporary(conn, false,oracle.sql.BLOB.DURATION_CALL); 
        outstrm = myBlob.getBinaryOutputStream();
        ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();

        InputStream in = myBase64EncodedClob.getAsciiStream();
        int c;
        while ((c = in.read()) != -1) 
        {
          byteOutStream.write((char) c);
        }          
        
        instrm = new ByteArrayInputStream(byteOutStream.toByteArray());
   
        try  // Input stream to output Stream
        {
          base64.decodeBuffer(instrm, outstrm);
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }

        outstrm.close();
        instrm.close();
        byteOutStream.close();
        in.close();
        conn.close();
      }

    }
    catch (Exception e) 
    {
        e.printStackTrace();
    }

    return myBlob;
    
  }  // Public decode

} // Class Base64


i supposed that the oracle reports returns an error not crash. the same way it works with when you have a number type instead you get a date type that will give you an error.

[Updated on: Tue, 27 August 2013 09:44]

Report message to a moderator

Re: Bad Images Cause Report to Crash [message #594257 is a reply to message #594255] Mon, 26 August 2013 15:50 Go to previous message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Unfortunately, I know less than nothing about Java so ... I'm useless here. I was hoping that you could, somehow, regarding what function returns, distinguish good from bad images.
Previous Topic: ORA-02248
Next Topic: oracle reports text formatting as runtime
Goto Forum:
  


Current Time: Thu Mar 28 11:56:31 CDT 2024