How to read OLE objects from Access ??

Hi,
I have an field of type OLE in my Access Database table. This field has some files stored in it in the form of attachment. The file types of the OLE objects can be different (xls,txt,doc). Now, I want to query the database and find the extension of the files and save it occordingly using java.
I'm using the following now.
JdbcOdbcInputStream jois = (JdbcOdbcInputStream) rs     .getBinaryStream("SupportingData");
byte[] supportingData = jois.readData();
String data = new String(supportingData);
I'm getting data in binary format and when I try to look into it, all I can see is the header info of the file.
Is there anyother way to read the OLE object easily ?
Please suggest.
Thanks,
Mary

How to read appended objects from file with ObjectInputStream? The short answer is you can't.
The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
Not trivial, but that's how you'd do it.

Similar Messages

  • How to read appended objects from file with ObjectInputStream?

    Hi to everyone. I'm new to Java so my question may look really stupid to most of you but I couldn't fined a solution by myself... I wanted to make an application, something like address book that is storing information about different people. So I decided to make a class that will hold the information for each person (for example: nickname, name, e-mail, web address and so on), then using the ObjectOutputStream the information will be save to a file. If I want to add a new record for a new person I'll simply append it to the already existing file. So far so good but soon I discovered that I can not read the appended objects using ObjectInputStream.
    What I mean is that if I create new file and then in one session save several objects to it using ObjectOutputStream they all will be read with no problem by ObjectInputStream. But after that if in a new session I append new objects they won't be read. The ObjectInputStream will read the objects from the first session after that IOException will be generated and the reading will stop just before the appended objects from the second session.
    The following is just a simple test it's not actual code from the program I was talking about. Instead of objects containing different kind of information I'm using only strings here. To use the program use as arguments in the console "w" to create new file followed by the file name and the strings you want save to the file (as objects). Example: "+w TestFile.obj Thats Just A Test+". Then to read it use "r" (for reading), followed by the file name. Example "+r TestFile.obj+". As a result you'll see that all the strings that are saved in the file can be successfully read back. Then do the same: "+w TestFile.obj Thats Second Test+" and then read again "+r TestFile.obj+". What will happen is that the strings only from the first sessions will be read and the ones from the second session will not.
    I am sorry for making this that long but I couldn't explain it more simple. If someone can give me a solution I'll be happy to hear it! ^.^ I'll also be glad if someone propose different approach of the problem! Here is the code:
    import java.io.*;
    class Fio
         public static void main(String[] args)
              try
                   if (args[0].equals("w"))
                        FileOutputStream fos = new FileOutputStream(args[1], true);
                        ObjectOutputStream oos = new ObjectOutputStream(fos);
                        for (int i = 2; i < args.length ; i++)
                             oos.writeObject(args);
                        fos.close();
                   else if (args[0].equals("r"))
                        FileInputStream fis = new FileInputStream(args[1]);
                        ObjectInputStream ois = new ObjectInputStream(fis);
                        for (int i = 0; i < fis.available(); i++)
                             System.out.println((String)ois.readObject());
                        fis.close();
                   else
                        System.out.println("Wrong args!");
              catch (IndexOutOfBoundsException exc)
                   System.out.println("You must use \"w\" or \"r\" followed by the file name as args!");
              catch (IOException exc)
                   System.out.println("I/O exception appeard!");
              catch (ClassNotFoundException exc)
                   System.out.println("Can not find the needed class");

    How to read appended objects from file with ObjectInputStream? The short answer is you can't.
    The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
    Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
    Not trivial, but that's how you'd do it.

  • Help! Print OLE object from report builder.

    Dear OTN Members,
    I would like to know how to print out a OLE object from
    report builder, because currently I face problem to print out
    the whole contain of the winword document file, because when I
    display the OLE on the form it will only display according the
    size I declare for it, it seems that it will not automatic
    extend the size itself. i.e. if I drag the size to one page in
    fact the maximum is one page, then when it display, it will only
    display maximum one page eventhough the document file maybe
    contain 10 page inside it. So when I print out the report it
    will only show me one page, so if you have any solution, pls
    share with me, thank you.
    null

    As far as I know you have to use OLE Item to work with the information. Unfortunately there is not any standart way to extract a source document from OLE. Some applications such as Word, Excel support OLE Automation, so you could use OLE2 package to save the document as a file, that is the easest way. But others don't, so you may have to use an undocumented way to extract a document.
    Take a look at the following thread:
    Subj: 6i to 9i Ole to LOB translations, How do you know the App. server?
    Re: 6i to 9i Ole to LOB translations, How do you know the App. server?
    P.S. If you can't extract some types of your documents, please let me khow.
    P.P.S. To extract a document through OLE2 package you could use something like the following. /I'm not sure the code is correct/:
    DECLARE
    handle ole2.obj_type;
    BEGIN
    ACTIVATE_SERVER('OLE1');
    handle := forms_ole.get_interface_pointer('OLE1');
    BEGIN
    -- Save a document to disk
    Args :=OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(Args, 'C:\test.doc'); -- file name
    OLE2.INVOKE(handle, 'SaveAs', Args);
    OLE2.DESTROY_ARGLIST(Args);
    EXCEPTION WHEN OTHERS THEN
    Message('Error');
    END;
    -- OLE2.RELEASE_OBJ(handle);
    END;

  • How to read a mail from sap inbox thru abap code?

    how to read a mail from sap INBOX thru abap code? can anyone tell me the technical approach? I NEED TO READ A MAIL and then need to pass the parameters to a bapi.
    Message was edited by:
            shahid mohammed syed

    Hi SSM,
    Did you manage to have your program working? I also have same requirement. I tried standard FM and BAPI but I always encounter authorization error when I tried accessing other user's mail. Thanks.
    Regards,
    Ryan

  • Doubt , how to display ole objects in report builder

    Please tell me, how to display ole objects in report builder.
    I mean i wanted to print ole object in report, so how to do that.

    Just to clarify Lixia's response.
    In Reports 9i we have deprecated our OLE functionality. Reports created in prior versions that contain OLE objects should still run, but you will not be able to create new reports containing OLE objects.

  • How to read some images from file system with webdynpro for abap?

    Hi,experts,
    I want to finish webdynpro for abap program to read some photos from file system. I may make MIMES in the webdynpro component and create photos in the MIMES, but my boss doesn't agree with me using this way. He wish me read these photos from file system.
    How to read some images from file system with webdynpro for abap?
    Thanks a lot!

    Hello Tao,
    The parameter
       icm/HTTP/file_access_<xx>
    may help you to access the pictures without any db-access.
    The following two links may help you to understand the other possibilities as well.
    The threads are covering BSP, but it should be useful for WebDynpro as well.
    /people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents
    http://help.sap.com/saphelp_sm40/helpdata/de/c4/87153a1a5b4c2de10000000a114084/content.htm
    Best regards
    Christian

  • How to move database objects from one user to another user

    Could someone help how to move database objects from one user to another user
    Thanks in advance

    Thanks a lot for the reply.
    Actually I wanted to know whether there is any command to change the owner ship of the table.
    For ex table1 belongs to user1. can the owner of table1 to be changed to owner2.
    directly using an oracle command. I knew that it can be done using import and export, since the table was 200 million thought the rename command would be faster instead of import and export.
    Thanks Billy for letting me know that it is not possible using oracle query.

  • How can i return object from oracle in my java code using pl/sql procedure?

    How can i return object from oracle in my java code using pl/sql procedure?
    And How can i returned varios rows fron a pl/sql store procedure
    please send me a example....
    Thank you
    null

    yes, i do
    But i can't run this examples...
    my problem is that i want recive a object from a PL/SQL
    //procedure callObject(miObj out MyObject)
    in my java code
    public static EmployeeObj callObject(Connection lv_con,
    String pv_idEmp)
    EmployeeObj ret = new EmployeeObj();
    try
    CallableStatement cstmt =
    lv_con.prepareCall("{call admin.callObject(?)}");
    cstmt.registerOutParameter(1, OracleTypes.STRUCT); // line ocurr wrong
    //registerOutParameter(int parameterIndex, int sqlType,String sql_name)
    cstmt.execute();
    ret = (EmployeeObj) cstmt.getObject(1);
    }//try
    catch (SQLException ex)
    System.out.println("error SQL");
    System.out.println ("\n*** SQLException caught ***\n");
    while (ex != null)
    System.out.println ("SQLState: " + ex.getSQLState ());
    System.out.println ("Message: " + ex.getMessage ());
    System.out.println ("Vendor: " + ex.getErrorCode ());
    ex = ex.getNextException ();
    System.out.println ("");
    catch (java.lang.Exception ex)
    System.out.println("error Lenguaje");
    return ret;
    Do you have any idea?

  • How to pass an object from jsp to other jsp using SendRedirect

    How to pass an object from one jsp to the other jsp using ssendRedirect with out using the session
    I am having 2 jsps
    x.jsp and y.jsp
    From x.jsp using sendRedirect iam going to y.jsp
    From x.jsp i have pass an object to the y.jsp
    Is it possible without putting the object in session
    Is it possible using EncodeUrl
    Please help me Its Urgent

    Is it possible without putting the object in sessionAnything is possible. Would you accept that it is very difficult?
    When you send a redirect, it tells the browser to send a new request for the target page. That means any request parameters/attributes are lost.
    Is it possible using EncodeUrl response.encodeURL() puts the session id into a url if the browser does not support cookies. It is purely for retaining the session.
    There are two ways that you can communicate across a sendRedirect.
    1 - use the session
    2 - pass a parameter in the url.
    parameters are string based, so passing objects is almost out of the question.
    Potentially you could serialize your object, encode it in base64 (so it is composed completely as characters) and pass it as a parameter to the other page, where you retrieve it, unencode it, and then load the serialized object.
    Or you can just use the session.

  • How to transport CU02 objects from one system to another?

    Hi,
    How to transport CU02 objects from one system (Development) to another (Quality)?

    You need to set up the object dependency IDOC in the partner profile.Message type is KNOMAS. The transaction to send is CLD2.

  • How to read Email address from TO field

    Hi,
    I am try to read email from outlook using JACOB api. now i can able to read all email from outlook.
    my problem is while i am read TO field for Mail , its return the display name instead of email address.
    please any one tell me how to read email address from TO,CC and BCC field.
    Thanks in advance,
    With Regards,
    Ganesh Kumar.L

    Hi all,
    I am solved my problem,
    First i am getting the Recipients object from mail item object,
    and recipient object i can get all my required details.
    Thanks,
    by
    ganesh

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • Reading an object from a binary file

    i am writing objects into my binary file using printwriter class. i am able to write objects into the file but i am having problems reading the object from the file. is there any other way of going about it. i tried using the objectoutputstream and object input stream class. but i am getting run time errors coz of something to do with serialization
    i am storing records as a object into a binary file so that it is easy to seek my records

    Of course you have trouble reading objects after you wrote them with a PrintWriter.
    You should rather have fixed the Serialization errors: only objkects that implement Serializable correctly can be serialized.

  • Hi,how can i transport objects from one server to other like (Dev To Qty)

    Hi Sir/madam,
       Can u explain how can i transport objects from one server to other like (Development To Quality To Production).
    Regards,
    Vishali.

    Hi Vishali,
    Step 1: Collect all Transports(with Packages) in Transports Tab(RSA1)- CTO
    Step 2: Release the subrequests first and then the main request by pressing Truck button
    Step 3: STMS or Customized transactions
    Object Collection In Transports:
    The respective Transports should have the following objects:
    1. Base Objects -
    a. Info Area
    b. Info object catalogs
    c. Info Objects
    2. Info Providers u2013
    a. Info Cubes
    b. Multi Providers
    c. Info Sets
    d. Data Store Objects
    e. Info Cube Aggregates
    3. Transfer Rules u2013
    a. Application Components
    b. Communication Structure
    c. Data Source replica
    d. Info Packages
    e. Transfer Rules
    f. Transformations
    g. Info Source Transaction data
    h. Transfer Structure
    i. Data sources (Active version)
    j. Routines & BW Formulas used in the Transfer routines
    k. Extract Structures
    l. (Note) If the transfer structures and related objects are being transferred without preceding
    Base Objects transport (e.g. while fixing an error) it is safer to transport the related Info
    Objects as well.
    4. Update Rules u2013
    a. Update rules
    b. Routines and formulas used in Update rules
    c. DTPs
    5. Process Chains u2013
    a. Process Chains
    b. Process Chain Starter
    c. Process Variants
    d. Event u2013 Administration Chains
    6. Report Objects u2013
    a. Reports
    b. Report Objects
    c. Web Templates
    Regards,
    Suman

  • How to read a data from USB port using JAVA

    hi all,
    i need to know how to read a data from USB port using java. any API are available for java ?.........please give your valuable ideas !!!!!!!!!
    Advance Thanks!!

    You can do this. Please use this link
    [http://www.google.co.in/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=uHu&q=java+read+data+from+usb+port&btnG=Search&meta=&aq=f&oq=]
    What research did you do of your own? Have you done some testing application and tried yourself??

Maybe you are looking for

  • How to Change UI element from input Field to Date Picker

    Hi All, One Custom View is created in which we are pulling some fields from a custom context node created using the value Node. For one of the field which is already an input field we need to convert it to date picker. in the GET_P_METHOD CASE IV_PRO

  • GNOME "Save as"-dialog appears hidden at the edges

    Hi, whenever the "Save as"-dialog of GNOME appears, pieces of it are hidden by the desktop edges/border. I cannot click the OK or Cancel-buttons not until I move it out of the edges. I'm using GNOME with pekwm as a WM, but I've experienced my problem

  • Web services test using WS Navigator doesnot return field values

    Hi experts, We are running ECC 6 (NW 7 Ehp1) ABAP stack and NW CE 7.1 with Java stack (J2EE Engine 7.11). We are trying to test web services using WS Navigator. We can logon to WS Navigator and perform the test. The test shows a success return code,

  • How to reboot my laptop

    product name WA971UA#ABC HARD DISK DOESNT EXIST

  • Resizing an image in iPhoto - HOW?

    iPhoto 09 is a pretty miserable application. Does anyone know how to simply resize an image - to a specific size - without having to mail or upload it with iPhoto's best guess for the chosen output?