How to cast a BLOB to OrdImage

Hi,
How can I cast or convert a BLOB to OrdImage? For example,
<import...>
public class ConvertBlobToOrdImage {
public static void main(String args[]) throws Exception {
// Load the Oracle JDBC driver:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database:
Connection conn =
DriverManager.getConnection(<"Your database connection">);
conn.setAutoCommit(false);
// Create a Statement:
Statement stmt = conn.createStatement();
String query = "SELECT blob FROM image_t where image_id = 1";
OracleResultSet rset = (OracleResultSet) stmt.executeQuery(query);
rset.next();
OrdImage imageProxy = (OrdImage) rset.getCustomDatum(1, OrdImage.getFactory()); // <-- java.lang.ClassCastException: oracle.sql.BLOB
rset.close();
int height = imageProxy.getHeight();
int width = imageProxy.getWidth();
System.out.println("Image Dimension: " + height + " x " + width);
System.out.println("Image Mime Type: " + imageProxy.getMimeType());
TIA,
Henry

xwindy wrote:
Does anyone knows how to cast a HashMap to HashMap<String, Object>?
the session.getAttribute return only a HashMapthere is no way to do this safely
you can use this annotation to suppress unchecked warnings
@SuppressWarnings("unchecked")

Similar Messages

  • HOW TO  CAST NVARCHAR2 TO BLOB

    Hello
    i must stock my data to a nvarchar2 data (unicode) and i must also make full text search on this column, oracle does not support full text search on unicode data, so i have decided to stock my unicode data to a blob clomun, after i can create a full text index and search data.
    my problem is how to cast nvarchar2 to blob in oracle. i'm using a vb program with adodb to write and read data from the db and i must write the data (unicode text) in the blob column using the right cast which allows me to use directly adodb to read information (i have tried this with sql server with a varbinary(max) column and it works : i write a nvarchar data to the verbinary(max) column using the cast function, after, adodb can read directly the information without any explicit cast) is this possible on oracle
    thank you for your help

    What is your database character set? If it's AL32UTF8 you shouldn't really need to use NVARCHAR2 at all - you can store Unicode data in a VARCHAR2 or CLOB column.
    BLOB doesn't seem like the right datatype to use - if it's text you want to index then it should be in a VARCHAR2 or a CLOB column. If you put it in a BLOB then you'll have to explicity tell Oracle not to treat it as a binary document, and you will have to handle all character set issues manually.
    I'm afraid I know nothing about VB or ADODB.

  • How to Get a BLOB Field from JDBC Coding

    Hi,
    I have written the JDBC Code to get the field values from the Table.
    There is a BLOB field in that table.
    How to get the BLOB ? What is the return type we should use.
    If it is Varchar then we can use rs.getString().
    If it is BLOB then what is the return type?
    Thanks in Advance

    Blob.
    You know, people like you really give me the urge to print out several hundred pages of Java API and smack them on their heads.

  • How to cast an Object into a specific type (Integer/String) at runtime

    Problem:
    How to cast an Object into a specific type (Integer/String) at runtime, where type is not known at compile time.
    Example:
    public class TestCode {
         public static Object func1()
    Integer i = new Integer(10); //or String str = new String("abc");
    Object temp= i; //or Object temp= str;
    return temp;
         public static void func2(Integer param1)
              //Performing some stuff
         public static void main(String args[])
         Object obj = func1();
    //cast obj into Integer at run time
         func2(Integer);
    Description:
    In example, func1() will be called first which will return an object. Returned object refer to an Integer object or an String object. Now at run time, I want to cast this object to the class its referring to (Integer or String).
    For e.g., if returned object is referring to Integer then cast that object into Integer and call func2() by passing Integer object.

    GDS123 wrote:
    Problem:
    How to cast an Object into a specific type (Integer/String) at runtime, where type is not known at compile time.
    There is only one way to have an object of an unknown type at compile time. That is to create the object's class at runtime using a classloader. Typically a URLClassloader.
    Look into
    Class.ForName(String)

  • How to implement remote blob storage in SharePoint 2013

    How to implement remote blob storage in SharePoint 2013 

    Try below:
    http://blogs.technet.com/b/wbaer/archive/2013/05/23/deploying-remote-blob-storage-with-sql-server-2012-alwayson-availability-groups.aspx
    If this helped you resolve your issue, please mark it Answered. You can reach me through http://itfreesupport.com/

  • How to cast vector to vector with out using loop. and how to override "operator =" of vector for this kind of condition.

    Hi All How to TypeCast in vector<>...  typedef  struct ...  to class... 
    //how to cast the vector to vector cast with out using loop
    // is there any way?
    //================ This is Type Definition for the class of ClsMytype=====================
    typedef struct tagClsMytype
    CString m_Name;
    int m_Index;
    double m_Value;
    } xClsMytype;
    //================ End of Type Definition for the class of ClsMytype=====================
    class ClsMytype : public CObject
    public:
    ClsMytype(); // Constructor
    virtual ~ClsMytype(); // Distructor
    ClsMytype(const ClsMytype &e);//Copy Constructor
    // =========================================
    DECLARE_SERIAL(ClsMytype)
    virtual void Serialize(CArchive& ar); /// Serialize
    ClsMytype& operator=( const ClsMytype &e); //= operator for class
    xClsMytype GetType(); // return the typedef struct of an object
    ClsMytype& operator=( const xClsMytype &e);// = operator to use typedef struct
    ClsMytype* operator->() { return this;};
    operator ClsMytype*() { return this; };
    //public veriable decleare
    public:
    CString m_Name;
    int m_Index;
    double m_Value;
    typedef struct tagClsMyTypeCollection
    vector <xClsMytype> m_t_Col;
    } xClsMyTypeCollection;
    class ClsMyTypeCollection : public CObject
    public:
    ClsMyTypeCollection(); // Constructor
    virtual ~ClsMyTypeCollection(); // Distructor
    ClsMyTypeCollection(const ClsMyTypeCollection &e);//Copy Constructor
    DECLARE_SERIAL(ClsMyTypeCollection)
    virtual void Serialize(CArchive& ar);
    xClsMyTypeCollection GetType();
    ClsMyTypeCollection& operator=( const xClsMyTypeCollection &e);
    ClsMyTypeCollection& operator=( const ClsMyTypeCollection &e); //= operator for class
    void Init(); // init all object
    CString ToString(); // to convert value to string for the display or message proposed
    ClsMyTypeCollection* operator->() { return this;}; // operator pointer to ->
    operator ClsMyTypeCollection*() {return this;};
    public:
    vector <ClsMytype> m_t_Col;
    //private veriable decleare
    private:
    //===================================================
    ClsMytype& ClsMytype::operator=( const xClsMytype &e )
    this->m_Name= e.m_Name;
    this->m_Index= e.m_Index;
    this->m_Value= e.m_Value;
    return (*this);
    //==========================Problem for the vector to vector cast
    ClsMyTypeCollection& ClsMyTypeCollection::operator=( const xClsMyTypeCollection &e )
    this->m_t_Col= (vector<ClsMytype>)e.m_t_Col; // how to cast
    return (*this);
    Thanks in Advance

    Hi Smirt
    You could do:
    ClsMyTypeCollection* operator->() {
    returnthis;};
    // operator pointer to ->
    operatorClsMyTypeCollection*()
    {returnthis;};
    public:
    vector<ClsMytype>
    m_t_Col;//??
    The last line with "vector<xClsMytype>
    m_t_Col;". It compiles but I doubt that is what you want.
    Regards
    Chong

  • How to Ftp a Blob attachment in a table using osb service

    How to Ftp a Blob attachment in a table using osb service
    I tried with DBadapter select it does not work ... For blob objects cant use select throws error as expected number got blob
    can call a stored procedure to write the file to some directory but that file will not be created with the same name of the file as stored in DB .. need to hard code the filename in utl file or if we pass a variable to get the name of the attachment file we have to use select query in cursor which throws error like above in step 2
    Can some body tell me how to get the blob attachment with the same name as it is stored in DB table
    Edited by: user13745573 on Jan 31, 2011 4:35 AM

    Hi,
    I want to send an attachment through email.
    But I want to pick the file from say local drive then how can i specify the path of the file in file name.
    Also, i dont want ot append the conent from payload to the file. i wanted to sendthe file as is.
    <ema:attachment>
    <ema:name></ema:name>
    <ema:type>text/plain</ema:type>
    <ema:content/>
    </ema:attachment>
    Please help.

  • How to modify the blob size, or how to set the size?

    i want to know how to modify the blob size, or how to set the size?
    what's the default size of blob?
    Thanks in advance.

    Blob datatype can contain binary data with a maximum size of 4 GB.
    when you enter 10kb file, the database will only use 10kb to store the file (depending on block size etc)
    if you want to modify the blob size, you may do like this:
    SQL> create materialized view t_mv refresh fast on commit
    2 as select id, dbms_lob.getlength(x) len from t;
    Materialized view created.
    SQL> alter table t_mv add constraint t_mv_chk check (len < 100);
    Table altered.

  • How to cast an object in JSF?

    I am working on a travel application. A user can have several bookings and a booking can have several components. A component can be either air or hotel. I want to list the user's bookings on the client using JSF datatable.
    <h:dataTable var="component" value="#{booking.components}">
    Now depending upon the class of component I need to present different information.
    My question is how to cast the variable in JSF ?
    Thanks

    You can use the String value of Object#getClass()#getName() to lookup the classname and evaluate it in the 'rendered' attribute.
    Basic example:
    package mypackage;
    public class Animal {}
    package mypackage;
    public class Cat extends Animal {}
    package mypackage;
    public class Dog extends Animal {}
    package mypackage;
    public class Fish extends Animal {}MyBeanpublic List<Animal> getList() {
        List<Animal> animals = new ArrayList<Animal>();
        animals.add(new Dog());
        animals.add(new Cat());
        animals.add(new Fish());
        return animals;
    }JSF<h:dataTable value="#{myBean.list}" var="item">
        <h:column>
            <h:outputText value="It's a Cat" rendered="#{item.class.name == 'mypackage.Cat'}" />
            <h:outputText value="It's a Dog" rendered="#{item.class.name == 'mypackage.Dog'}" />
            <h:outputText value="It's a Fish" rendered="#{item.class.name == 'mypackage.Fish'}" />
        </h:column>
    </h:dataTable>As far there is no way to cast objects in JSF.
    Edit
    If you find it useful, move the classname request to the superclass:
    public class Animal {
        public String getType() {
            String className = getClass().getName();
            return className.substring(className.lastIndexOf('.') + 1);
    }Which makes life easier without struggling with package names:<h:outputText value="It's a Cat" rendered="#{item.type == 'Cat'}" />
    <h:outputText value="It's a Dog" rendered="#{item.type == 'Dog'}" />
    <h:outputText value="It's a Fish" rendered="#{item.type == 'Fish'}" />Message was edited by:
    BalusC

  • How to display a BLOB column in ADF.

    How to display a BLOB column in ADF.

    hi agowlikar786
    Maybe the forum thread "ADF BC : download BLOB " can help
    at ADF BC : download BLOB
    regards
    Jan

  • How load File as Blob in Oracle Table?

    Hi, I am beginner in ODI.
    How load File as BLOB in Oracle Table?

    Ah so nice, a FAQ, by someone who can't use online resources!
    Any explanation why Google is broken for you?
    Here is the code I use to load a jpg.
    procedure upd_portrait(p_person_id in number, p_file_name in varchar2) is
    l_blob blob;
    l_bfile bfile;
    begin
    update person
    set portrait = empty_blob()
    where id = p_person_id
    returning portrait into l_blob;
    l_bfile := bfilename('MY_IMAGES', p_file_name);
    dbms_lob.fileopen(l_bfile);
    dbms_lob.loadfromfile(l_blob, l_bfile, dbms_lob.getlength(l_bfile));
    dbms_lob.fileclose(l_bfile);
    end;
    Sybrand Bakker
    Senior Oracle DBA

  • How to cast ArrayList to ....

    Hi,
    I got an ArrayList and its values are (1,2,3)
    List tempList = new ArrayList();
    tempList.add("1");
    tempList.add("2");
    tempList.add("3");
    I am wondering how to convert it to an int [] array.
    int [] tempInt;
    I know that I can do this : tempList.toArray
    but I don't know how to cast this to int[] type of array
    (note: not integet [] , just int[])
    Can anyone help? thanks a lot.

    Note: It would be much more efficient to use the wrapper classes for storing primitives in a Vector/ArrayList/LinkedList/... :
    tempList.add(new Integer(1));
    tempList.add(new Integer(2));
    tempList.add(new Integer(3));
    (getting the array as an int[] still requires a for-loop)

  • How to cast object type to integer type?

    Hi,
    Object [] temp;
    Int [] value;
    How can I assign temp to value? (value = temp?)
    In other words how to cast array of type object to array of type integer?
    Thanks a lot.

    Hi,
    Object [] temp;
    Int [] value;
    How can I assign temp to value? (value = temp?)
    In other words how to cast array of type object to
    array of type integer?
    Thanks a lot.That my friend, is (sometimes) illegal. other times use
    value = (Integer[]) temp;
    Pray that temp is holding an Integer array so that you dont throw a runtime exception.
    I am assuming you know the diff between "int" and "Integer".

  • How to cast presentation variable

    Hi,
    How to cast the presentation variable in answers
    Thanks in advance
    naresh

    Hi Naresh,
    Have you tried to use the CAST function?
    CAST(@{test}{123} as char)
    With the above column Formula in Answers Request I can able to view the result 123, which is the default value specified the presentation variable 'test'.
    Hope this will helps you..
    -Vency

  • Converter via trigger from blob to ordimage

    Hi i make trigger for convertion blob to ordimage but when i execute it i got errors what should i do to fix this ?
    create or replace
    TRIGGER obrazy.dodanie_id23233
    AFTER INSERT OR UPDATE ON fotki
    FOR EACH ROW
    BEGIN
    INSERT INTO FOTKIORD (FOTKAID1, FOTKA1)
         VALUES (:NEW.fotkaid, ORDSYS.SI_STILLIMAGE(:NEW.fotka));
    END;
    Warning: oci_execute(): ORA-29400: data cartridge error IMG-00701: unable to set the properties of an empty image ORA-06512: at "ORDSYS.ORDIMERRORCODES", line 75 ORA-06512: at "ORDSYS.ORDIMERRORCODES", line 65 ORA-06512: at "ORDSYS.ORDIMERRORCODES", line 29 ORA-06512: at "ORDSYS.ORDIMG_PKG", line 33 ORA-06512: at "ORDSYS.ORDIMAGE", line 945 ORA-06512: at "ORDSYS.SI_STILLIMAGE", line 58 ORA-06512: at "OBRAZY.DODANIE_ID23233", line 2 ORA-04088: error during execution of trigger 'OBRAZY.DODANIE_ID23233' in C:\Program Files (x86)\Zend\Apache2\htdocs\upload.php on line 45

    994229 wrote:
    I created trigger and it works fine but for si_stillimag i cant why ???? Works fine for me:
    SQL> select  *
      2    from  v$version
      3  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> create table fotki(
      2                     fotkaid number not null,
      3                     fotka blob,
      4                     constraint fotki_pk primary key(fotkaid)
      5                    )
      6  /
    Table created.
    SQL> create table fotkiord(
      2                        fotkaid1 number not null,
      3                        fotka ordsys.si_stillimage
      4                       )
      5    segment creation immediate
      6  /
    Table created.
    SQL> create or replace
      2    trigger fotki_aiur
      3      after insert
      4         or update
      5      on fotki
      6      for each row
      7      begin
      8          insert
      9            into fotkiord
    10            values(
    11                   :new.fotkaid,
    12                   case
    13                     when :new.fotka is null then null
    14                     when dbms_lob.compare(:new.fotka,empty_blob()) = 0 then null
    15                     else ordsys.si_stillimage(:new.fotka)
    16                   end
    17                  );
    18  end;
    19  /
    Trigger created.
    SQL> -- NULL fotka
    SQL> insert
      2    into fotki
      3    values(
      4           1,
      5           null
      6          )
      7  /
    1 row created.
    SQL> -- empty_blob() fotka
    SQL> insert
      2    into fotki
      3    values(
      4           2,
      5           null
      6          )
      7  /
    1 row created.
    SQL> -- actual image fotka
    SQL> DECLARE
      2      v_blob blob;
      3      v_bfile BFILE := BFILENAME('TEMP','HONDA CR-V.jpg');
      4  BEGIN
      5      DBMS_LOB.CREATETEMPORARY(v_blob,TRUE);
      6      DBMS_LOB.fileopen(v_bfile,DBMS_LOB.file_readonly);
      7      DBMS_LOB.LOADFROMFILE(v_blob,v_bfile,DBMS_LOB.GETLENGTH(v_bfile));
      8      DBMS_LOB.FILECLOSE(v_bfile);
      9      INSERT
    10        INTO FOTKI
    11        VALUES(3,v_blob);
    12      DBMS_LOB.FREETEMPORARY(v_blob);
    13  END;
    14  /
    PL/SQL procedure successfully completed.
    SQL> select  *
      2    from  fotki
      3  /
       FOTKAID
    FOTKA
             1
             2
             3
    FFD8FFE000104A46494600010101006000600000FFDB004300020101020101020202020202020203
    0503030303030604040305070607070706070708090B0908080A0807070A0D0A0A0B0C0C0C0C0709
       FOTKAID
    FOTKA
    SQL> select  *
      2    from  fotkiord
      3  /
      FOTKAID1
    FOTKA(CONTENT_SI(LOCALDATA, SRCTYPE, SRCLOCATION, SRCNAME, UPDATETIME, LOCAL), C
             1
             2
             3
    SI_STILLIMAGE(ORDSOURCE('FFD8FFE000104A46494600010101006000600000FFDB00430002010
    10201010202020202020202030503030303030604040305070607070706070708090B0908080A080
      FOTKAID1
    FOTKA(CONTENT_SI(LOCALDATA, SRCTYPE, SRCLOCATION, SRCNAME, UPDATETIME, LOCAL), C
    7070A0D0A0A0B0C0C0C0C0709', NULL, NULL, NULL, '05-MAY-13', 1), 126992, 'JFIF', 6
    48, 1152, 'image/jpeg', '24BITRGB', 'JPEG', NULL, NULL, NULL, NULL, NULL, NULL)
    SQL>SY.

Maybe you are looking for

  • Errors when using Web Content Reporting

    Hi, has anybody installed Web Content Reporting from the SDN download successful? We got through the db-update and ran the aggregator component. But we have two errors: 1.) When restarting the service, we get the following error: Jan 18, 2005 11:33:0

  • JMIP Condition type is not  Replicated from Po to MIGO excise tab

    Dear Experts I Maintained inventorized excise condition types in the Purchase order . Like JMIP, JEC2, JSEI . while doing the GR , Excise values are not coming in the excise Tab. Please help me. Thanks Reddy Edited by: Subbas on Aug 4, 2010 2:56 PM

  • Calling a BPS Layout from Reporting

    We are trying to call a BPS planning layout from the report by drilling down on the forecasting data in a Report.  We are creating a report of Actuals and Forecast Data.  The delta will be calculated as an Accrual and the accrual could require the us

  • Where's The Activity Window in Safari 6?

    ?

  • Authorizing songs in iTunes after performing an erase and install

    Hi This one should be a simple one for someone to solve. I'm running Panther 10.3.9 - I've had to perform a 'erase and install', and now all the tunes I'ved purchased from iTunes are not authorised to play. I understand this is because my iTunes acco