JPA2 - downloading large objects from database

Hi,
I would like to enable user to download large (up to 20Mb) files, stored in Oracle database.
I think I should use a stream, but I don't know how to get JPA to return a stream of Large Object. Can you help?
I'm using EclipseLink.

Hello,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Pagination#Using_a_ScrollableCursor describes using a scrollable cursor to return entities. Since this is going through JPA (you didn't mention what api you are using to access EclipseLink) you will want to be careful to manage/clear your cache appropriately so it does not use all your available memory. You will probably want to make this query read-only, and clear the cache after a few iterations using em.clear().
http://wiki.eclipse.org/Introduction_to_EclipseLink_Queries_(ELUG)#Stream_and_Cursor_Query_Results describes and has links to using streams and cursors with the native EclipseLink read queries.
Best Regards,
Chris

Similar Messages

  • Bdoc Error: PRODUCT_SRV while download Customizing Objects from ECC to CRM

    Hello,
    we have tried to download Customizing Objects from ERP to CRM we getting Bdoc error PRODUCT_SRV
    Please any help us in replicating customizing objects ECC6.0 to CRM7.0 Ehp1.
    Bdoc Type:PRODUCT_SRV
    Thanks,
    adi

    Adi,
    Where do you get the erorr? If you're downloding PRODUCT_SRV, then this is not a customizing object. Please check for related inbound and outbound queues in CRM and ECC for errors. Please also check SMW01 and see if you have any BDoc's in error. Give us the full error text of any errors found.
    If you get the problem with customzing objects, please let us the object name(s). Is it just one object or all customizing object?
    Best regards,
    Brian.

  • How to download a file from database

    Hi,
    My flex application contains a form that uploads a file into the server. This file is however saved in the database, and not on the disk. Most of the tutorials in the database explains how to download a file by passing the file's url to the "download" function of the fileReference Object. That dsnt work for me as my file is saved in the database.
    How do I download this file from the server ?
    For example, in php, we would do smthing like this :
    $content = $file_to_download['content'];
    $size = $file_to_download['content_size'];
    $type = $file_to_download['content_type'];
    $name = $file_to_download['filename'];
    header("Content-type:$type");
    header("Content-length:$size");
    header("Content-Disposition:attachment;filename=$name");
    header("Content-Description:PHP Generated Data");
    echo $content;
    When executing this file, it opens up the "download file" dialog box. How do i get the same effect in flex 4 ?

    You need the bytes use FileReference.download() and after download you can save
    it on disk with FileReference.save(); You also need FP 10 at least I think. Use
    the docs they are less error pron than mi memory :).
    C

  • Large Objects in Database?

    Is there ever an arguement for keeping large objects (1-25 MB) inside the database, versus storing pointers to the files at locations outside?

    Thank you for the reference. I reviewd these section on your suggestion but I guess I'm hoping for some empirical feedback ( I'm new t o Oracle Dbs). Blob vs. Bfile is the dilemma. The way I read it, the difference in storage location, and the BFILE read only restrictions. So deciding which datatype will be based upon machine conditions for the BFILE side; i.e. is the file server OS stable/accessible? how often would the BFILE date need to be rewritten vs. adding metadata to the BLOB? is it faster to rewrite the BFILE than the BLOB with the addtional metadata? I just don't have any experience to draw from and was looking for a general direction. Thanks for your time

  • Downloading a file from Database [Blob field]

    I am trying to write an application which can upload and download files [Excel, Word etc.] to/from an Oracle 9i database Blob field. I am using Java/JSP for the same.
    The upload part works just fine. However, when I try to download the file that I uploaded, I get an error.
    A dialog box comes up asking me to Open/Save the file. However, when I try to save it, it says
    �Internet Explorer cannot download �..tion=download&planId= testplan from localhost
    Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later.�
    I am using IE 6.0. I tested the same with Firefox browser and was able to download the file.
    Can anyone help?
    Code:
    Following is the code I am using for the same.
    /* Code to retrieve from Blob field */
    String sqlString = "SELECT PLAN_DOCUMENT_NAME,PLAN_DOCUMENT FROM BRS_PLAN_DESCRIPTION WHERE PLAN_ID = ?";
    ps = con.prepareStatement(sqlString);
    ps.setString (1,planId);
    rs = ps.executeQuery();
    while (rs.next()) {
         fileBytes = rs.getBytes("PLAN_DOCUMENT");
         fileName = rs.getString("PLAN_DOCUMENT_NAME");
    brsPlanDocument.setPlanId(planId);
    brsPlanDocument.setFileName(fileName);
    brsPlanDocument.setFileBytes(fileBytes);
    /* Code for download */
    String fileName = brsPlanDocument.getFileName();
    String fileType = fileName.substring(fileName.indexOf(".")+1,fileName.length());
    if (fileType.trim().equalsIgnoreCase("txt"))
         response.setContentType( "text/plain" );
    else if (fileType.trim().equalsIgnoreCase("doc"))
         response.setContentType( "application/msword" );
    else if (fileType.trim().equalsIgnoreCase("xls"))
         response.setContentType( "application/vnd.ms-excel" );
    else if (fileType.trim().equalsIgnoreCase("pdf"))
         response.setContentType( "application/pdf" );
    else if (fileType.trim().equalsIgnoreCase("ppt"))
         response.setContentType( "application/ppt" );
    else
         response.setContentType( "application/octet-stream" );
    response.setHeader("Content-Disposition","attachment; filename=\""+fileName+"\"");
    response.setHeader("cache-control", "no-cache");
    byte[] fileBytes=brsPlanDocument.getFileBytes();
    ServletOutputStream outs = response.getOutputStream();
    outs.write(fileBytes);
    outs.flush();
    outs.close();

    Hi,
    is this problem solved for you, I am also writing the java code to store different files in blob fields in database(db2udb) and allow users to open them through jsp pages. Upload seems to be working fine.....My big problem is only excel files are opened properly in both IE and Firefox. Word files, image files are not getting opened. Any suggestion as what I could be doing wrong....my jsp is kind of similar to the above one...
    thanks in advace, please guide me
    long pmsId = new Long(request.getParameter("pmsId")).longValue();
    String fileName = request.getParameter("fileName");
    int fileSeq = new Integer(request.getParameter("fileSeq")).intValue();
    if(fileName.endsWith("txt")) {
    response.setContentType("text/plain");
    log.debug(" this is a text file");
    } else if(fileName.endsWith("xls")) {
    response.setContentType("application/vnd.ms-excel");
    log.debug(" this is a excel file");
    } else if(fileName.endsWith("gif")) {
    response.setContentType("image/gif");
    log.debug(" this is a image file");
    } else if(fileName.endsWith("doc")) {
    response.setContentType("application/msword");
    log.debug(" this is a doc file");
    } else if(fileName.endsWith("pdf")) {
    response.setContentType("application/pdf");
    log.debug(" this is a pdf file");
    } else if(fileName.endsWith("ppt")) {
    response.setContentType("application/ppt");
    log.debug(" this is a ppt file");
    } else {
    response.setContentType("application/everythingelse");     
    log.debug(" this is a unknown ile");
    response.setHeader("Content-Disposition", "attachment;filename="+fileName);
    OutputStream out1 = response.getOutputStream();
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    db2Conn = DriverManager.getConnection("jdbc:db2:TESTDB","db2admin","db2fv1000");
    //log.debug("connection obtained");
    pstmt = db2Conn.prepareStatement(" SELECT * FROM UPLOADDOCS WHERE PMSID = ? AND DOCSEQ = ? ");
    //log.debug("statemenmt prepared");
    pstmt.setLong(1, pmsId);
    pstmt.setInt(2, fileSeq);
    rs = pstmt.executeQuery();
    int count = 0;
    if(rs.next()){
    InputStream is = rs.getBinaryStream("DOCUMENT"); //"is" is
    //now the binary data
    //of the file
    byte[] buf = new byte[4096];
    int len;
    while ((len = is.read(buf)) > 0)
         out1.write(buf, 0, len);
    out1.close();
    out1.flush();

  • Use WEBUTIL for upload and download file to/from Database

    Dear friends
    I have a table with three columns (id , name , myDoc) myDoc is a BLOB, I would like upload word documents or PDFs or images to myDoc column, I use Oracle Form 10g, I try to use webutil to solve my problem, but I couldn't, Please help me.
    Thanks

    # Details
    # transfer.database.enabled : Can be TRUE or FALSE - allows you to disable
    # upload and download from the database server.
    # transfer.appsrv.enabled : Can be TRUE or FALSE - allows you to disable
    # upload and download from the application
    # server.
    # transfer.appsrv.workAreaRoot: The root of the location in which WebUtil can
    # store temporary files uploaded from the client.
    # If no location is specified, Application Server
    # user_home/temp will be assumed.
    # This location is always readable and writable
    # no matter what the settings in
    # transfer.appsrv.* are. This setting is
    # required if you need the Client side
    # READ/WRITE_IMAGE_FILE procedures.
    # transfer.appsrv.accessControl:Can be TRUE or FALSE - allows you to indicate
    # that uploads and downloads can only occur from
    # the directories named in the
    # transfer.appsrv.read.n and
    # transfer.appsrv.write.n entries and their
    # subdirectories. If this setting is FALSE,
    # transfers can happen anywhere.
    # transfer.appsrv.read.<n>: List of directory names that downloads can read
    # from.
    # transfer.appsrv.write.<n>: List of directory names that uploads can write
    # to.
    #NOTE: By default the file transfer is disabled as a security measure
    transfer.database.enabled=true
    transfer.appsrv.enabled=true
    transfer.appsrv.workAreaRoot=
    transfer.appsrv.accessControl=TRUE
    #List transfer.appsrv.read.<n> directories
    transfer.appsrv.read.1=c:\temp
    #List transfer.appsrv.write.<n> directories
    transfer.appsrv.write.1=c:\temp

  • Cannot Download Large Attachments from .Mac Into Mail

    I recently opened a .Mac account, and can't download any emails with attachments larger than about 300k into Mail. Smaller attachments will eventually download, but take an age (2-3minutes minimum). The progress 'clock' alongside the Inbox icon in Mail won't complete a full revolution (I assume from this Mail isn't syncing properly with the .Mac server) and I have to force quit the program to get it to close.
    I can, however, send and receive emails OK otherwise, and if I go into my .Mac account via webmail I can download any attachments from there no problem, at a normal rate for my broadband connection (1Mb on Tiscali). Apple Support couldn't help much, and suggested I post here. Any ideas?? It's driving me mad! Ta in advance. BBM

    BBM,
    Welcome to the Discussions.
    Do you have an email account provided by your ISP?
    If so, does it exhibit anything like this behavior?
    In Mail Preferences/Accounts/Advanced, what are your
    selections for Keep copies for Offline Viewing?
    Ernie
    Hi Ernie, and sorry for the slow reply, been away for a few days. My ISP email account doesn't exhibit any of this, and the advanced settings for .mac are to keep all messages and attachments. Going by other posts on similar topics, it looks like a major bug in Mail/.mac syncing. Have you heard of any progress in solving it at Mac's end yet? Regards, BBM

  • Reading large large string from database

    I am reading is a large string value. It's data type in Oracle is CLOB. I was originally casting it to vARCHAR2(4000) in the select statement, but just realized the data can be larger than 4000. I took out the cast and have tried changing to several data types, but they all error out. How can I read in string data greater than 4000 characters?

    You must use Java to do this, the Execute Script operation makes it simple. I have put together a little process to demonstrate, and I can paste the Java from the Execute Script step below.
    It's all in the data-typing. In the sample I built, the BigString and NewBigString process variables are of LiveCycle type "string" with unlimited size. These become CLOBs in the database. When read as a CLOB object using JDBC, converted to Java Strings, they then can be loaded into the LiveCycle Process data and the API handles the rest.
    Let me know if I'm not clear enough with my explanation.
    Jeff A Yates
    http://www.avoka.com
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import javax.sql.DataSource;
    import javax.naming.InitialContext;
    int processId = patExecContext.getProcessDataIntValue("/process_data/@id");
    InitialContext context = new InitialContext();
    Connection connection = ((DataSource)context.lookup("java:/IDP_DS")).getConnection();
    String queryQuery = "select bigdocument, bigstring from tb_pt_workwithxlobs where process_instance_id = ?";
    PreparedStatement queryStatement = connection.prepareStatement(queryQuery);
    try {
    queryStatement.setInt(1, processId);
    ResultSet results = queryStatement.executeQuery();
    results.next();
    java.sql.Blob documentBlob = results.getBlob(1);
    com.adobe.idp.Document document = new com.adobe.idp.Document(documentBlob.getBinaryStream());
    patExecContext.setProcessDataValue("/process_data/@NewBigDocument", document);
    java.sql.Clob stringClob = results.getClob(2);
    patExecContext.setProcessDataValue("/process_data/@NewBigString", stringClob.getSubString(1L, (int)stringClob.length()));
    } catch(Exception ex) {
    ex.printStackTrace();
    queryStatement.close();
    connection.close();

  • Show larger image from database

    Hello.
    On my detail page I have a small picture that shows a product
    generated from an access database. The particular record is linked
    from the master page by url. What I want to do is enable customers
    to click on that image and by doing so show them a larger version
    of which I made a seperate variable with the path name (Works). How
    do I do this? What is the best and most elegant way? Pop up?

    Duplicate of https://forums.oracle.com/thread/2610899
    Timo

  • Download byte[]'s from database from pageflow Controller

    I cannot seem to download a byte[] array (of a stored excel file in Oracle) using a pageFlow controller. I want to use the controller because the byte[]'s are gathered from a JDBCControl and the controller can of course gain easy access to the JDBCControl.
              Of course the desired end result is that the browser will prompt the user to open/save the dowloaded file.
              Has anyone been able to do this?

    Hi Jinchun,
    Thank you for your suggestions. Below are my comments:
    Upgrade the SSRS to date - I am a developer and the server is owned by an infrastructure team. It is not at all realistic for me to ask them to upgrade the server because of my issues. If it helps though, we are using SSRS 2012.
    Run the sub report separately to check whether the issue happens - I have done this and it doesn't make a difference because I'm only retrieving basic parameters from the main report. The subreport queries the binary data from the database itself.
    Simply the custom code(e.g. Just show message box) - Unfortunately, I didn't have time to try this one before the business agreed to the other working option which is downloading the files to a shared drive. I know it sounds so lame from a web development
    perspective but really I think this is not a bad compromise for using SSRS.
    Thanks again for your efforts,
    Vanessa

  • ADF How to Download BLOB File from Database Column

    Hi,
    We have one blob Database Column in which we use for storing attachments(eg Image,.doc or.zip) . We are able to upload attachments.
    How can I build page which will access that particular record and will be able to download attachment in it.
    It should prompt to Save and then we can save it on Local machine.
    Thanks,
    Jit

    Sorry, I don't get your question.
    If you have a file name including the suffix like 'Test.file.doc' you can pass this file name as parameter to the method and get the MIME type back. I your sample it would be "application/msword"
    String mime = ContentTypes.get("Test.file.doc");
    public class ContentTypes
        public static String get(String fileName)
            String mime = null;
            String ext = fileName.toLowerCase();
            if (ext.endsWith(".pdf"))
                mime = "application/pdf";
            else if (ext.endsWith(".doc"))
                mime = "application/msword";
            else if (ext.endsWith(".xls"))
                mime = "application/msexcel";
            else if (ext.endsWith(".docx"))
                mime = "application/msword2007";
            else if (ext.endsWith(".xlsx"))
                mime = "application/msexcel2007";
            else if (ext.endsWith(".ppt"))
                mime = "application/vnd.ms-powerpoint";
            else if (ext.endsWith(".rar"))
                mime = "application/octet-stream";
            else if (ext.endsWith(".zip"))
                mime = "application/zip";
            else if (ext.endsWith(".jpg"))
                mime = "image/jpeg";
            else if (ext.endsWith(".jpeg"))
                mime = "image/jpeg";
            else if (ext.endsWith(".gif"))
                mime = "image/gif";
            else if (ext.endsWith(".png"))
                mime = "image/png";
            return mime;
    }Timo

  • ADF Re-Mapping objects from database

    Hello
    I am developing a web application using ADF, this is my situation: the data base has changed after I maped it to java objects, how can I update the data objects to include those new changes?
    Thanks

    Hi,
    assuming you are using ADF BC you just need to right click on your entity object and select Synchronise with database.
    If new attributes (columns) are added you need to edit your VO and add them in.
    Brenden

  • Download large library from iTunes Match to iPhone

    I subscribe to iTunes Match and want to download a large playlist (approximately 9,000 songs, 60 GB) to my iPhone (for use when I don't have a wifi connection).  Downloading over wifi is impossibly slow - it does a few hundred songs per day.  And it gets hung up every few hours so I have to restart.  Downloading the entire playlist would take (literally) weeks of running 24 hours per day.  This is not feasible.  I can sync the playlist through iTunes and copy to my phone if I turn off iTunes Match on the phone.  But then when I turn on iTunes Match on my phone back on (to listen to the rest of my library that won't fit on my phone) it deletes all the music already on the phone (the large playlist that I spent weeks downloading over wifi). 
    Any suggestions on how to get around this problem?  Bottom line is that I want this large playlist (my favourite stuff) resident on the phone so I can listen without a wifi connection.  But I also want iTunes Match turned on so that I can listen to everything when I do have a wifi connection.  Any way to do this without downloading the playlist over wifi?
    iPhone 6, 128GB, iOS 8.1.1

    i have been dealing with the same issue since I started using iTunes match. it's the worst.
    i recently restored my iphone 6 (same model) and now it's even doing something else.
    im trying to download 1230 songs and it only even attempts to download about 100 at a time. it freezes on the rest and doesn't even put them in a queue.
    this issue needs SERIOUS attention.

  • Download table data from se16 to excel

    Hi I am trying to download table data from SE16 (field widths, descriptions etc) to Excel, but cannot as the option local file is greyed out under System>List>Save.
    Table>Print doesn't let mn downlaod either, jsut print. As I have 50 tables to download, is there a better option than copy and paste into excel?
    Thanks

    Hi,
    You can use the T-code SE11 for downloading the values from database table, after entering Table name ,
    click on Display (F7), it will take you to new screen, then enter (CtrlAltF10),
    Now enter the input values and execute.
    Kindly check with this.
    Best Regards,
    Vasu.

  • Treat objects from named query as new ones

    Hello,
    I use TopLink 11.1.1.1.0 and I need to do following. I want to read object from database with named query and let TopLink treat them like new object created in java. Is it possible? Obejcts are in one table but the named query computes them with select from several different tables, so this obejcts are not present in the table.
    Why I need it? It is import of data from one module of our application to another. Previously it was done in java. About 500 000 objects were read in one module just to convert into 20 000 objects in another module. If database does this conversion (named query with grouping which reads the 20 000 objects) it is much faster and take much less memory.
    What I can do is to create new class with the same fields query this objects and then copy them to object I need. But I don't like creating new class just for this.
    Thank for any help
    Frank

    Thanks for help I solved it different way eventually. I made a stored procedure which inserts data to the table of SOURCE_ITEMS. First I call stored procedure, then I load all new created SOURCE_ITEMS with ReadAllQuery (I have business parameters by which to select them) and make post processing in java with them. I used StoredProcedureCall in TopLink so if exception occurs and transaction rollbacks, stored procedure will rollback as well (I tried it, works for sure:).
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName(SQL_IMPORT_CALL);
    call.addNamedArgumentValue(SQL_IMPORT_PARAM_1, getId());
    call.addNamedArgumentValue(SQL_IMPORT_PARAM_2, getXXX().getId());
    call.addNamedArgumentValue(SQL_IMPORT_PARAM_3, getYYY.getId());
    call.addNamedArgumentValue(SQL_IMPORT_PARAM_4, getZZZ());
    DataModifyQuery query = new DataModifyQuery();
    query.setCall(call);
    query.setShouldBindAllParameters(true);
    // insert of imported SOURCE_ITEMS
    ctx.executeQuery(query);
    Thanks Chris and hope this will help to somebody else as well..
    Frank
    Edited by: user604333 on Nov 17, 2010 12:20 PM
    Edited by: user604333 on Nov 17, 2010 12:20 PM
    Edited by: user604333 on Nov 17, 2010 12:20 PM

Maybe you are looking for

  • Help!!!!! Regular Expressions!!

    I am trying to use Regular Expressions, for parsing. For that the pakage required is java.util.regex.*; I am also using the import statement in a sample code. But compiling it, gives an error, ERRORS: Replacement.java:6: package java.util.regex does

  • Submit to SAP button

    Hi folks, Would like to know, how 'Submit to SAP' button working in Adobe interactive forms.how this button is synchronised with outlook(IXOS server). For example, if a travel request created, click on this button it will take us to a new mail with t

  • File Name in Place command changes

    I have Photoshop CS5 on a MAC and have developed actions that use the Place command.  The initial recorded action places a file called FILENAME.PSD into the currently open file.  If I use the Finder to rename this external file (outside of Photoshop)

  • How do I get an old aluminium cable replaced?

    I have been visited by an Openreach engineer who advised me my cable is very old and needed replacing. I spoke to BT who said my Broadband was above the min (20mbps) so they wouldn't do anything. I am paying for 76Mbps and my neigbour (on a better ca

  • What does the Parameter attribute mean?

    I am looking at proxy class generated by dot.net connector, following is the method I am looking at: Crm_Icss_Srvreq_Create(.....) following parameter is one of the many parameters, [RfcParameter(AbapName= "IV_CONT_ITEM_GUID",RfcType=RFCTYPE.RFCTYPE_