CSV to Oracle DB - Upload File

Dear All,
              I have a scenario where I need to upload data in csv format to tables in Oracle DB. Here is the detailed description of problem.
a) User selects a csv file on his desktop which has data in it in csv format.
b) A BLOB is inserted in Oracle DB table "FileData_Tab" once user clicks on upload button.
c) A row insert trigger will be invoked on inserting the data which invokes a <b>stored procedure to reconstruct the csv file, read the data from it, and update the data accordingly to respective tables fields</b>.
My only concern is in step 'c'. Is it possible in Oracle to have a stored procedure which re-constructs a csv file, and updates the tables.
Thanks in advance.
Regards,
Chaitanya

Here you have an article I used to get csv from an oracle cursor with pl/sql functions. There is another to insert from a csv. They are very simple. Maybe it could be help for you with a little modification.
http://articles.techrepublic.com.com/5100-9592_11-5259821.html
Best regards. Be generous.
Aníbal Pozo.

Similar Messages

  • Uploaded Files stored in Oracle 10G database or in Unix File system

    Hey All,
    I am trying to understand best practices on storing uploaded files. Should you store within the database itself (this is the current method we are using by leveraging BLOB storage) or use a BFILE locator to use the files system storage (we have our DB's on UNIX) . . .or is there another method I should be entertaining? I have read arguments on both sides of this question. I wanted to see what answers forum readers could provide!! I understand there are quite a few factors but the situation I am in is as follows:
    1) Storing text and pdf documents.
    2) File sizes range from a few Kb to up to 15MB in size
    3) uploaded files can be deleted and updated / replaced quite frequently
    Right now we have an Oracle stored procedure that is uploading the files binary data into a BLOB column on our table. We have no real "performance" problems with this method but are entertaining the idea of using the UNIX file system for storage instead of the database.
    Thanks for the insight!!
    Anthony Roeder

    Anthony,
    First word you must learn here in this forum is RESPECT.
    If you require any further explanation, just say so.
    BLOB compared with BFILE
    Security:
    BFILEs are inherently insecure, as insecure as your operating system (OS).
    Features:
    BFILEs are not writable from typical database APIs whereas BLOBs are.
    One of the most important features is that BLOBs can participate in transactions and are recoverable. Not so for BFILEs.
    Performance:
    Roughly the same.
    Upping the size of your buffer cache can make a BIG improvement in BLOB performance.
    BLOBs can be configured to exist in Oracle's cache which should make repeated/multiple reads faster.
    Piece wise/non-sequential access of a BLOB is known to be faster than a that of a BFILE.
    Manageability:
    Only the BFILE locator is stored in an Oracle BACKUP. One needs to do a separate backup to save the OS file that the BFILE locator points to. The BLOB data is backed up along with the rest of the database data.
    Storage:
    The amount of table space required to store file data in a BLOB will be larger than that of the file itself due to LOB index which is the reason for better BLOB performance for piece wise random access of the BLOB value.

  • Upload file in JSP with Oracle Database 10gR2

    How to upload file with oracle database 10gR2??
    i can't find how to upload..
    i've tried to create a procedure in oracle and execute in netbeans but the file save in directory and then from directory save to database.
    it means the file save in 2 location, in directory and database..
    does anybody know how to save file direct from the JSP file into database without save in directory?
    this is the procedure..
    create or replace PROCEDURE load_file (
    p_id number,
    p_photo_name in varchar2) IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('DIR_TEMP', p_photo_name);
    -- insert a NULL record to lock
    INSERT INTO temp_photo
    *(id, photo_name, photo)*
    VALUES
    *(p_id , p_photo_name ,EMPTY_BLOB())*
    RETURNING photo INTO dst_file;
    -- lock record
    SELECT photo
    INTO dst_file
    FROM temp_photo
    WHERE id = p_id
    AND photo_name = p_photo_name
    FOR UPDATE;
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE temp_photo
    SET photo = dst_file
    WHERE id = p_id
    AND photo_name = p_photo_name;
    -- close file
    dbms_lob.fileclose(src_file);
    END load_file;

    Well your Oracle procedure is designed to load a file, so that's what it does. If you want it to load from a data stream such as an upload, you need to rewrite it accordingly.
    So far this is not a Java question at all.

  • Upload files like Word,Autocad,Pdf using oracle Forms

    Using Oracle Forms i want upload files like word,autocad,excel,pdf to be stored in oracle database and a download option to download these files.This must be done only by means Forms for intranet.

    Hello,
    Have a look at this paper:
    Webutil Store and Edit documents

  • Uploading File with Umlaute (German) - solved

    I am using the .csv to table package from Vikas. The uploaded file comes from one of
    my customers. The customer is supposed to save an .xls file as .csv and upload it into
    a collection. So far so good. Whenever there are Umlaute (ä, ö, ü), they are not translated
    properly and the collection shows a character ¿ instead. So, a REPLACE would not work
    there. Is there any experience on how to solve this problem? I have no chance to educate
    my customer not to use Umlaute or to ask him to check the settings in their excel, since
    they are numerous and anonymous.
    Thanks,
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

    Okay,
    With a little help from John Scott, I found a solution changing this part of the package to:
    FOR i IN 1 .. l_record.COUNT
             LOOP
                htmldb_collection.update_member_attribute
                                         (p_collection_name      => p_collection_name,
                                          p_seq                  => l_seq_id,
                                          p_attr_number          => i,
                                          p_attr_value           => CONVERT
                                                                       (l_record
                                                                               (i),
                                                                        'UTF8',
                                                                        'WE8ISO8859P1'
             END LOOP;and it works properly for the German characters.
    Thanks,
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Upload file into db,sos!

    I am working on upload into and download from database. I am
    using jspsmartupload api.
    Please help me any one worked on this api.. I am getting an
    error like
    An error occurs : java.sql.SQLException: Internal Error: Unable
    to construct a Datum from the specified input 0 file(s) uploaded
    in the database
    When the file size is less then 4KB.. and I am getting an error
    like this when the file size is grater then 4KB I am getting an
    error like this..
    An error occurs : java.sql.SQLException: ORA-01008: not all
    variables bound
    When I was trying to insert a row into database by using result
    set by using
    rs.moveToInsertRow();
    rs.insertRow();
    I am getting another error like
    java.sql.SQLException: Io exception: Connection reset by peer:
    JVM_recv in socke
    t input stream read
    at oracle.jdbc.dbaccess.DBError.throwSqlException
    (DBError.java)
    at oracle.jdbc.dbaccess.DBError.throwSqlException
    (DBError.java)
    at oracle.jdbc.driver.OracleResultSetImpl.internal_close
    (OracleResultSet
    Impl.java)
    at oracle.jdbc.driver.OracleResultSetImpl.close
    (OracleResultSetImpl.java
    at oracle.jdbc.driver.ScrollableResultSet.close
    (ScrollableResultSet.java
    at oracle.jdbc.driver.UpdatableResultSet.close
    (UpdatableResultSet.java)
    at examples.jsp.smart.sample4_jsp_1._jspService
    (sample4_jsp_1.java:166)
    at com.sun.jsp.runtime.HttpJspBase.service
    (HttpJspBase.java:87)
    at javax.servlet.http.HttpServlet.service
    (HttpServlet.java:840)
    at
    com.sun.jsp.runtime.JspServlet$JspServletWrapper.service
    (JspServlet.j
    ava:88)
    at com.sun.jsp.runtime.JspServlet.serviceJspFile
    (JspServlet.java:218)
    at com.sun.jsp.runtime.JspServlet.service
    (JspServlet.java:294)
    at javax.servlet.http.HttpServlet.service
    (HttpServlet.java:840)
    at com.sun.web.core.ServletWrapper.handleRequest
    (ServletWrapper.java:155
    at com.sun.web.core.Context.handleRequest
    (Context.java:414)
    at com.sun.web.server.ConnectionHandler.run
    (ConnectionHandler.java:139)
    HANDLER THREAD PROBLEM: java.io.IOException: Socket Closed
    java.io.IOException: Socket Closed
    at java.net.PlainSocketImpl.getInputStream(Unknown
    Source)
    at java.net.Socket$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native
    Method)
    at java.net.Socket.getInputStream(Unknown Source)
    at com.sun.web.server.ConnectionHandler.run
    (ConnectionHandler.java:161)
    Here is the code..
    ResultSet rs = stmt.executeQuery("SELECT Ta.* FROM
    MP1.TBL_UPLOAD Ta where ID =1");
    // if the resultset is not null
    if (rs.next()){
    // Initialization
    mySmartUpload.initialize(pageContext);
    // Upload
    mySmartUpload.upload();
    // upload file in the DB if this file is not
    missing
    if (!mySmartUpload.getFiles().getFile
    (0).isMissing()){
    try {
    file://rs.moveToInsertRow();
    file://rs.updateInt("ID",2);
    rs.updateString("FILENAME",
    mySmartUpload.getFiles().getFile(0).getFileName());
    // Add the current file in the
    DB field
    System.out.println("I am before
    update Row()" + mySmartUpload.getFiles().getFile(0).getFileName
    mySmartUpload.getFiles().getFile
    (0).fileToField(rs,"ATTACHMENT");
    System.out.println("I am before
    update Row()");
    // Update
    file://rs.insertRow();
    file://rs.first();
    rs.updateRow();
    count++;
    } catch(Exception e) {
    out.println("An error occurs : "
    + e.toString());
    // Display the number of files uploaded
    out.println(count + " file(s) uploaded in the
    database.");
    rs.close();
    stmt.close();
    con.close();
    null

    You could try using an Excel VB script to do it. I'm considering doing the same thing. We receive reports from vendors in Excel spreadsheet formats currently. The users are now forced to save the document as a CSV file and then call up an Oracle Forms page and enter the CSV filename. I use the utility TEXT_IO to read the file in its comma delimited form. For me, this process is highly dependant on the user correctly saving the file. This causes me to perform very specific data format checking in my PL scripts. To alleviate this, I'm considering using the VB script as I mentioned. I haven't investigated it, its just an idea. Of course it'll be dependent on whether I can connect to the Oracle DB within the VB script in Excel.
    Good luck.
    Ed.

  • UPLOAD FILE

    Hi.. i did some research on loading the csv file, and its pretty cool. But I ran into this problem, I was uploading test.csv file as given here
    Re: Loading a CSV file into a table(Vikas Plz)
    and mainly the demo provided by Vikas.
    and it works pretty well. But when my csv file gets bigger in size, although i can see the data is getting inserted into the table, but the front end session is timing out.
    So I thought if i can upload test.csv to wwv_flow_files and then using UTL_FILE, i can transfer it to the unix box and then run some scripts. WHY? bcos our team is already doing this kind of thing.. load csv file to unix box and insert data of csv file to the tables. So its pretty much done.. only thing is to provide capability to upload the file to unix box.
    Does it make sense? If yes.. then how can i upload file to wwv_flow_files using File browse item.
    Suggestions / Ideas?
    pb

    Hi Prashant,
    Did you already have a look here: http://download-west.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32469/up_dn_files.htm
    This provides you pretty good information how to create an upload/download application in APEX.
    Dimitri

  • Remove link for uploaded files in application

    Hi all,
    I've been following the tutorial on how to upload and download files in application at http://download-uk.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32469/up_dn_files.htm. I have now created my own table which stores the uploaded files and can download them successfully. I would now like to add the ability to delete these files within the application and was wondering what the best way of doing this was?
    I would like to add another column to the displayed report with a 'Remove file' link for each listed file, which when clicked would delete the file from the table. I've already tried using a similar method to the one used to upload the files (instead of uploading the file, the called procedure deletes it from the table using the specified ID), but this causes the application to display a blank page when the link is clicked, which I dont want (but does delete the file).
    I would appreciate any suggestions.
    Regards,
    Dave

    Dave,
    See the login page:
    http://htmldb.oracle.com/pls/otn/f?p=31517:101
    There are details on how to access the application builder, where you can see how the
    setup of that download, delete, upload application has been done.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Delete an uploaded file (in custom table) from a report

    Hi,
    I have a report of uploaded files (the files are saved in my own table, not in APEX_APPLICATION_FILES) - I'd like to add a delete link to each file in my report so that the user can delete a particular file.
    How do I go about doing this?
    Thanks.

    Melissa,
    It is now working. You missed couple of things:
    1. javascript in the header
    2. you were pointing to the page 1 and your process was on the page 2
    3. you passed the value to a non existing item on the page 3
    4. the request which would fire the delete process was triggered by a wrong request
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Is there a way to silently upload files?

    Ok, so I've taken the plunge. I've started working on an AIR
    app using Flash CS3. I'm putting together a little app that will
    keep my online store updated with all the product updates from our
    wholesaler. This includes parsing a csv file, downloading product
    images from the wholesaler, updating the database, and then
    uploading the images to our server.
    The problem is that AIR does not seem to have the
    functionality to silently upload files! Sure, I can use the
    file.reference object to fire off the browse method, which then
    opens the OS file browser window BUT I would really like the whole
    thing to be hands off. In the past, I've written these types of
    apps using Visual Studio but I haven't touched VS in two years.
    Has anyone run across a way to silently upload or ftp files
    in AIR?

    Hey Oliver,
    Thanks for your answer--the fact that it CAN be done has
    gotten me a lot further on finding a solution. Here's what I have
    so far. As it runs, I can see the progress and completion of the
    upload but I'm still not getting it saved. I'm uploading it to a
    ColdFusion processing page.
    AS3 Code:
    import flash.filesystem.*;
    import flash.net.URLRequest;
    //Silent File Upload (no browse window)
    function imageUpload(imageName,uploadPage):void
    trace('Starting Upload of ' + imageName + '\n');
    var myFile:File =
    File.applicationDirectory.resolvePath(imageName);
    var request:URLRequest = new URLRequest(uploadPage);
    request.method = URLRequestMethod.POST;
    myFile.addEventListener(ProgressEvent.PROGRESS,progressHandler);
    myFile.addEventListener(Event.COMPLETE,completeHandler);
    myFile.upload(request,"theFile");
    function progressHandler(event:ProgressEvent):void {
    var file:FileReference = FileReference(event.target);
    var pLoaded =
    Math.ceil(event.bytesLoaded/event.bytesTotal*100);
    trace(pLoaded + '% uploaded');
    function completeHandler(event:Event):void
    trace ('Upload complete.');
    var uploadPage = "
    http://www.aaronbday.com/upload_file.cfm";
    imageUpload("angelic_cat.jpg",uploadPage);
    Here's the CFM page:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    <title>Upload File</title>
    </head>
    <body>
    <cfif isDefined("form.theFile")>
    <!---we only want images--->
    <cffile
    action="upload"
    destination="#ExpandPath("test/")#"
    filefield="theFile"
    nameconflict="overwrite"
    accept="image/jpg,image/jpeg,image/gif,image/pjpeg"
    >
    <cfoutput><img src="test/#cffile.serverFile#"
    /></cfoutput>
    <cfelse>
    <form method="post" action="upload_file.cfm"
    enctype="multipart/form-data">
    <input type="file" name="theFile" />
    <input type="submit" name="Submit" />
    </form>
    </cfif>
    </body>
    </html>
    Any ideas? Thanks!

  • Problem while uploading file from application server to internal tab in BG

    Hi all,
    When i see the file  in application server.data is like this
    #################00\);_(#####}#-#}###############################00\);_(#####}#-#}###############################00\);_(*#####}#-#}#########
    ###################}###}#############A#############???#00\);_(*#################;_(@_)  ########???#        ########???#        ########???###
    #######???#########}###}#############)##############}##00\);_(*#################;_(@_)  ############        ############        ##############
    ###################}#A#}#############:##############}##00\);_(#################;_(@_)  }###}##############################00\);_(*##########
    #######???#########}#-#}#############F#################00\);_(#####}###}#############@#################00\);_(#################;_(@_)  #####
    ###################}#-#}#############3#################00\);_(#####}#U#}#############E#################00\);_(#################;_(@_)  #####
    Because the csv which is uploaded has dropdowns and some formattings.
    when download from tcode cg3y i am getting correct file
    When try to use open(binary mode) and read dataset i getting data as it is (junk).
    i need to process in background.
    Any help.
    Rhea.

    upload file to string format
    begin of ty_tab,
    string type char200,
    end of ty_tab.
    loop at ty_tab into string
    use statement replace string into tab deliminated fromat(particular occurance in string)
    now call class to break string at tab into fields
    endloop.
    DATA : BEGIN OF i_data OCCURS 0,
            data(200)    TYPE c,       "To hold Upload file data
           END OF i_data.
    OPEN DATASET v_str FOR INPUT
                              IN TEXT MODE
                              ENCODING DEFAULT IGNORING CONVERSION ERRORS.
        IF sy-subrc EQ 0.
          DO.
    *Read a line from input file
            READ DATASET v_str INTO i_data-data.
            IF sy-subrc NE 0.
              EXIT.
            ENDIF.
    *Append record to an internal table
            APPEND i_data.
            CLEAR: i_data.
          ENDDO.
    *Close the file
          CLOSE DATASET v_str.
    *---Start of inserti
    LOOP AT i_data.
            REPLACE ALL OCCURRENCES OF '"' IN i_data WITH '#'.
            SPLIT i_data AT cl_abap_char_utilities=>horizontal_tab
                                INTO i_doc-pvaudt
                                     i_doc-pvpate
                                     i_doc-vecatc
                                     i_doc-vhvend
                                     i_doc-vhidt8
                                     i_doc-vhinvn
                                     i_doc-vhhexp
                                     i_doc-vhiref.

  • Upload file to global directory in Dev, Q&A and Prod!

    I have an upload application in BSP, that uploads files to for example /usr/sap/BWD/files
    this works in Development, but of course this directory is not available in Production, so BSP won't work there.
    Isn't it possible to use one global directory?
    Right now somebody created for us a directory, that's the same on all 3 systems (Dev, Q, and Production)
    this dir is
    on Development:  DIR_TRANS     /usr/sap/transBW
    on Quality:  DIR_TRANS     /usr/sap/transBW
    on Production:  DIR_TRANS     /usr/sap/trans
    notice the small difference in path in Production... Is there a way to use the DIR_TRANS instead of the real path?
    my application writes data like this:
    fname = '/usr/sap/CBD/files/FILE.CSV'.
    OPEN DATASET fname FOR OUTPUT in TEXT MODE encoding default.
    if sy-subrc gt 0.
    WRITE: / 'Error opening file'.
    endif.
    LOOP AT data_TAB INTO LIN.
    TRANSFER LIN TO FNAME.
    ENDLOOP.
    CLOSE DATASET FNAME.
    thanks a lot, points will be rewarded for usefull answers!
    thanks!

    use transaction FILE to create logical path for the actual file path.
    and then use FM
    call function 'FILE_GET_NAME'
             exporting
                  client           = sy-mandt
                  logical_filename = pil_file  "Input logical file name
                  operating_system = sy-opsys
             importing
                  file_name        = p_i_file  "Physical file name
             exceptions
                  file_not_found   = 1
                  others           = 2.
    Regards
    Raja

  • We can use JSR-168 JPS portlet upload file,

    We can use JSR-168 JPS portlet upload file,
    here is the source for you referrence:
    upload file can use JSR168 portlet,
    1,CustomizablePortlet.java File
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.ResourceBundle;
    import javax.portlet.*;
    import oracle.webdb.utils.SimpleStringBuffer;
    public class CustomizablePortlet extends GenericPortlet {
    private static final String TITLE_KEY = "title";
    protected static final String OK_ACTION = "ok_action";
    protected static final String APPLY_ACTION = "apply_action";
    protected static final PortletMode PREVIEW_MODE = new PortletMode("preview");
    protected static final PortletMode EDIT_DEFAULTS_MODE = new PortletMode("EDIT_DEFAULTS");
    protected static final PortletMode ABOUT_MODE = new PortletMode("ABOUT");
    public CustomizablePortlet() {
    public String getTitle(RenderRequest request) {
    return request.getPreferences().getValue("title", getPortletConfig().getResourceBundle(request.getLocale()).getString("javax.portlet.title"));
    public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.print("<FORM ACTION=\"");
    out.print(getEditFormSubmitURL(request, response));
    out.println("\" METHOD=\"POST\">");
    out.println("<TABLE BORDER=\"0\">");
    out.println("<TR>");
    out.println("<TD WIDTH=\"20%\">");
    out.println("<P CLASS=\"portlet-form-field\" ALIGN=\"RIGHT\">Title:");
    out.println("</TD>");
    out.println("<TD WIDTH=\"80%\">");
    out.print("<INPUT CLASS=\"portlet-form-input-field\" TYPE=\"TEXT\" NAME=\"");
    out.print("title");
    out.print("\" VALUE=\"");
    out.print(getTitle(request));
    out.println("\" SIZE=\"20\">");
    out.println("</TD>");
    out.println("</TR>");
    out.println("<TR>");
    out.println("<TD COLSPAN=\"2\" ALIGN=\"CENTER\">");
    out.print("<INPUT CLASS=\"portlet-form-button\" TYPE=\"SUBMIT\" NAME=\"");
    out.print("ok_action");
    out.print("\" VALUE=\"OK\">");
    out.print("<INPUT CLASS=\"portlet-form-button\" TYPE=\"SUBMIT\" NAME=\"");
    out.print("apply_action");
    out.print("\" VALUE=\"Apply\">");
    out.println("</TD>");
    out.println("</TR>");
    out.println("</TABLE>");
    out.println("</FORM>");
    protected String getEditFormSubmitURL(RenderRequest request, RenderResponse response) {
    return response.createActionURL().toString();
    public void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.print("Help for <i><b>");
    out.print(getTitle(request));
    out.println("</b></i>.");
    public void doAbout(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    String aboutHTML = (new SimpleStringBuffer(30)).append("/about_").append(getPortletName()).append(".html").toString();
    PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(aboutHTML);
    response.setContentType("text/html");
    if(rd != null) {
    rd.include(request, response);
    } else {
    PrintWriter out = response.getWriter();
    out.print("<p class=\"portlet-font\">This is the about page for ");
    out.print(getTitle(request));
    out.print(".</p><p class=\"portlet-font\">");
    out.print("To customize the contents of this page, create a file named '");
    out.print(aboutHTML.substring(1));
    out.print("' in the Portlet web application's root directory containing HTML ");
    out.print("to appear here. ");
    out.print("Alternatively, override the <code>CustomizablePortlet</code> ");
    out.println("class's <code>doAbout()</code> method.</p>");
    public void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    WindowState state = request.getWindowState();
    if(!state.equals(WindowState.MINIMIZED)) {
    PortletMode mode = request.getPortletMode();
    if(mode.equals(PREVIEW_MODE))
    doView(request, response);
    else
    if(mode.equals(EDIT_DEFAULTS_MODE))
    doEdit(request, response);
    else
    if(mode.equals(ABOUT_MODE))
    doAbout(request, response);
    else
    super.doDispatch(request, response);
    } else {
    super.doDispatch(request, response);
    public void processAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, IOException {
    String newTitle = request.getParameter("title");
    PortletPreferences prefs = request.getPreferences();
    prefs.setValue("title", newTitle);
    prefs.store();
    if(request.getParameter("ok_action") != null) {
    actionResponse.setPortletMode(PortletMode.VIEW);
    actionResponse.setWindowState(WindowState.NORMAL);
    2,FileUploadPortlet.java file
    import java.io.*;
    import javax.activation.DataHandler;
    import javax.mail.MessagingException;
    import javax.mail.internet.MimeBodyPart;
    import javax.portlet.*;
    import oracle.portal.portlet.sample.CustomizablePortlet;
    public class FileUploadPortlet extends CustomizablePortlet
    private static final String FILE_PARAM = "file";
    private static final String SUBMIT_PARAM = "submit";
    private static final String DEFAULT_CHARSET = "ISO-8859-1";
    private static final String uploadRoot = "";
    public FileUploadPortlet()
    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.print("<form action=\"");
    out.print(response.createActionURL().toString());
    out.println("\" enctype=\"multipart/form-data\" method=\"post\">");
    out.println("<center><table border=\"0\">");
    out.println("<tr>");
    out.print("<td class=\"portlet-form-field\" align=\"right\">");
    out.print("Please browse to an HTML file:");
    out.println("</td>");
    out.print("<td>");
    out.print("<input class=\"portlet-form-input-field\" type=\"file\" name=\"");
    out.print("file");
    out.print("\">");
    out.println("</td>");
    out.println("</tr>");
    out.println("<tr>");
    out.println("<td colspan=\"2\" align=\"center\">");
    out.print("<input type=\"submit\" class=\"portlet-form-button\" name=\"");
    out.print("submit");
    out.print("\" value=\"Display\">");
    out.println("</td>");
    out.println("</tr>");
    out.println("</table>");
    out.println("</form>");
    String lastFile = request.getPreferences().getValue("file", null);
    if(lastFile != null) {
    out.println("<hr width=\"100%\"><br>");
    out.print(lastFile);
    public void processAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, IOException {
    FormDataParser parsedRequest = new FormDataParser(request);
    MimeBodyPart mbp = parsedRequest.getMimeBodyPart("file");
    if(mbp == null)
    super.processAction(request, actionResponse);
    else
    try {
    String fileName= mbp.getFileName();
    int splash = fileName.lastIndexOf("\\");
    if(splash != -1)
    fileName = fileName.substring(splash +1, fileName.length()).trim();
    String contentType = mbp.getContentType();
    String charSet = getCharsetFromContentType(contentType);
    int sepIndex = contentType.indexOf(';');
    if(sepIndex != -1)
    contentType = contentType.substring(0, sepIndex).trim();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    mbp.getDataHandler().writeTo(bos);
    bos.close();
    String content = new String(bos.toByteArray(), charSet);
    FileOutputStream fos = new FileOutputStream(fileName);
    fos.write(bos.toByteArray());
    fos.close();
    PortletPreferences prefs = request.getPreferences();
    prefs.setValue("file", fileName + "upload ok");
    prefs.store();
    catch(MessagingException me) {
    throw new PortletException(me);
    public static String getCharsetFromContentType(String contentType) {
    int lastPos;
    if((lastPos = contentType.indexOf(';')) == -1)
    return "ISO-8859-1";
    lastPos++;
    String lowerContentType = contentType.toLowerCase();
    int nextPos;
    do {
    nextPos = lowerContentType.indexOf(';', lastPos);
    String param;
    if(nextPos == -1)
    param = lowerContentType.substring(lastPos).trim();
    else
    param = lowerContentType.substring(lastPos, nextPos).trim();
    if(param.startsWith("charset=") && param.length() > 8)
    return param.substring(8);
    lastPos = nextPos + 1;
    } while(nextPos != -1);
    return "ISO-8859-1";
    3,FormDataParser.java file
    import java.io.*;
    import java.util.*;
    import javax.activation.DataSource;
    import javax.mail.MessagingException;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMultipart;
    import javax.portlet.ActionRequest;
    import javax.portlet.PortletException;
    public class FormDataParser {
    private static final String MULTIPART_PREFIX = "multipart/";
    private static final String MULTIPART_FORM_DATA = "multipart/form-data";
    private static final String PLAIN_TEXT = "text/plain";
    private ActionRequest mWrappedRequest;
    private Map mParams;
    private Map mBodyParts;
    private boolean mIsInitialized;
    private boolean mHasMultipart;
    public FormDataParser(ActionRequest request) {
    mWrappedRequest = request;
    public String getParameter(String name) throws PortletException {
    String value = mWrappedRequest.getParameter(name);
    if(value != null)
    return value;
    initParameters();
    if(!mHasMultipart)
    return null;
    List paramList = (List)mParams.get(name);
    if(paramList != null)
    return (String)paramList.get(0);
    else
    return null;
    public String[] getParameterValues(String name) throws PortletException {
    String values[] = mWrappedRequest.getParameterValues(name);
    if(!mHasMultipart)
    return values;
    initParameters();
    List valueList = (List)mParams.get(name);
    if(valueList == null)
    return values;
    int size = valueList.size();
    if(values != null) {
    List newValueList = new ArrayList(values.length + size);
    newValueList.addAll(Arrays.asList(values));
    newValueList.addAll(valueList);
    valueList = newValueList;
    values = new String[size];
    valueList.toArray(values);
    return values;
    public MimeBodyPart getMimeBodyPart(String name) throws PortletException {
    initParameters();
    if(!mHasMultipart) {
    return null;
    } else {
    List parts = (List)mBodyParts.get(name);
    return parts != null ? (MimeBodyPart)parts.get(0) : null;
    public MimeBodyPart[] getMimeBodyParts(String name) throws PortletException {
    initParameters();
    if(!mHasMultipart)
    return null;
    List parts = (List)mBodyParts.get(name);
    if(parts == null) {
    return null;
    } else {
    MimeBodyPart mimeBodyParts[] = new MimeBodyPart[parts.size()];
    parts.toArray(mimeBodyParts);
    return mimeBodyParts;
    private void initParameters() throws PortletException {
    if(mIsInitialized)
    return;
    String contentType = mWrappedRequest.getContentType();
    if(contentType == null) {
    mIsInitialized = true;
    return;
    int sepIndex = contentType.indexOf(';');
    if(sepIndex != -1)
    contentType = contentType.substring(0, sepIndex).trim();
    if(contentType.equalsIgnoreCase("multipart/form-data")) {
    mParams = new HashMap(20);
    mBodyParts = new HashMap(20);
    DataSource ds = new DataSource() {
    public InputStream getInputStream() throws IOException {
    return mWrappedRequest.getPortletInputStream();
    public OutputStream getOutputStream() throws IOException {
    throw new IOException("OutputStream not available");
    public String getContentType() {
    return mWrappedRequest.getContentType();
    public String getName() {
    return getClass().getName();
    try {
    MimeMultipart multipartMessage = new MimeMultipart(ds);
    parseMultiPart(multipartMessage, null);
    catch(MessagingException me) {
    throw new PortletException(me);
    catch(IOException ioe) {
    throw new PortletException(ioe);
    mHasMultipart = true;
    mIsInitialized = true;
    private void parseMultiPart(MimeMultipart multipartMessage, String parentFieldName) throws MessagingException, IOException {
    int partCount = multipartMessage.getCount();
    for(int i = 0; i < partCount; i++) {
    javax.mail.BodyPart part = multipartMessage.getBodyPart(i);
    if(part instanceof MimeBodyPart) {
    MimeBodyPart mimePart = (MimeBodyPart)part;
    String disps[] = mimePart.getHeader("Content-Disposition");
    if(disps != null && disps.length != 0) {
    String disp = disps[0];
    String lcDisp = disp.toLowerCase();
    int nameStart;
    int nameEnd;
    if((nameStart = lcDisp.indexOf("name=\"")) != -1 && (nameEnd = lcDisp.indexOf("\"", nameStart + 6)) != -1)
    parentFieldName = disp.substring(nameStart + 6, nameEnd);
    if(parentFieldName != null)
    if(mimePart.getContentType().toLowerCase().startsWith("multipart/")) {
    Object content = mimePart.getContent();
    if(content instanceof MimeMultipart)
    parseMultiPart((MimeMultipart)content, parentFieldName);
    } else
    if((nameStart = lcDisp.indexOf("filename=\"")) != -1 && (nameEnd = lcDisp.indexOf("\"", nameStart + 10)) != -1) {
    List values = (List)mBodyParts.get(parentFieldName);
    if(values == null) {
    values = new ArrayList(1);
    mBodyParts.put(parentFieldName, values);
    values.add(mimePart);
    } else
    if(mimePart.getContentType().toLowerCase().startsWith("text/plain")) {
    Object content = mimePart.getContent();
    if(content instanceof String) {
    List values = (List)mParams.get(parentFieldName);
    if(values == null) {
    values = new ArrayList(1);
    mParams.put(parentFieldName, values);
    values.add((String)content);
    4.web.xml file
    <?xml version = '1.0' encoding = 'ISO-8859-1'?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <display-name>hanhuiwen OracleSamplePortlets</display-name>
    <description>hanhuiwen Oracle Sample Portlet Application</description>
    <servlet>
    <servlet-name>portletdeploy</servlet-name>
    <servlet-class>oracle.webdb.wsrp.server.deploy.PortletDeployServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
    <servlet-name>portletjaxrpc</servlet-name>
    <servlet-class>com.sun.xml.rpc.server.http.JAXRPCServlet</servlet-class>
    <init-param>
    <param-name>configuration.file</param-name>
    <param-value>/WEB-INF/WSRPService_Config.properties</param-value>
    </init-param>
    </servlet>
    <servlet>
    <servlet-name>portletresource</servlet-name>
    <servlet-class>oracle.webdb.wsrp.server.ResourceServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>ChartServlet</servlet-name>
    <display-name>Chart Servlet</display-name>
    <description>Demo image-generating servlet</description>
    <servlet-class>oracle.portal.portlet.sample.chart.ChartServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
    <servlet-name>uix</servlet-name>
    <servlet-class>oracle.cabo.servlet.UIXServlet</servlet-class>
    <init-param>
    <param-name>oracle.cabo.servlet.pageBroker</param-name>
    <param-value>oracle.cabo.servlet.xml.UIXPageBroker</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>ChartServlet</servlet-name>
    <url-pattern>/chart*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>portletjaxrpc</servlet-name>
    <url-pattern>/portlets*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>portletresource</servlet-name>
    <url-pattern>/portletresource*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>uix</servlet-name>
    <url-pattern>*.uix</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>uix</servlet-name>
    <url-pattern>/uix/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>60</session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>index.uix</welcome-file>
    </welcome-file-list>
    <!--
    LogLevel controls the amount of information logged. There are 7 log levels:
    0 - logging disabled
    1 - configuration
    2 - severe error
    3 - warning
    4 - throwing exception
    5 - performance
    6 - information
    7 - debug
    The oracle.portal.log.Logger interface defines methods that map to these 7
    log levels. However, there are also 2 methods that do not map to log
    levels. These methods are included for backwards compatibility and data
    logged using these methods will always be logged regardless of the log level.
    -->
    <env-entry>
    <env-entry-name>oracle/portal/log/logLevel</env-entry-name>
    <env-entry-type>java.lang.Integer</env-entry-type>
    <env-entry-value>7</env-entry-value>
    </env-entry>
    </web-app>
    5.portlet.xml
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
    <portlet>
    <description xml:lang="en">A portlet that demonstrates the file upload features of the Java Portlet Specification.</description>
    <portlet-name>FileUpload</portlet-name>
    <portlet-class>FileUploadPortlet</portlet-class>
    <expiration-cache>0</expiration-cache>
    <supports>
    <mime-type>text/html</mime-type>
    <portlet-mode>help</portlet-mode>
    <portlet-mode>about</portlet-mode>
    <portlet-mode>edit_defaults</portlet-mode>
    </supports>
    <supported-locale>en</supported-locale>
    <portlet-info>
    <title>File Upload Portlet</title>
    <short-title>File Upload</short-title>
    <keywords>File,Upload, Portlet</keywords>
    </portlet-info>
    </portlet>
    <custom-portlet-mode>
    <description xml:lang="en">This mode should be used by the portlet to display information on the portlet's purpose, origin, version, etc.</description>
    <portlet-mode>about</portlet-mode>
    </custom-portlet-mode>
    <custom-portlet-mode>
    <description xml:lang="en">This mode signifies that the portlet should render a screen to set the default values for the modifiable preferences that are typically changed in the EDIT screen. Calling this mode requires that the user must have administrator rights.</description>
    <portlet-mode>edit_defaults</portlet-mode>
    </custom-portlet-mode>
    <custom-portlet-mode>
    <description xml:lang="en">This mode should be used by the portlet to render output without the need of having back-end connections or user specific data available.</description>
    <portlet-mode>preview</portlet-mode>
    </custom-portlet-mode>
    <user-attribute>
    <name>user.name.given</name>
    </user-attribute>
    <user-attribute>
    <name>user.name.family</name>
    </user-attribute>
    <user-attribute>
    <name>user.name.middle</name>
    </user-attribute>
    <user-attribute>
    <name>user.name.nickname</name>
    </user-attribute>
    <user-attribute>
    <name>user.bdate</name>
    </user-attribute>
    <user-attribute>
    <name>user.business-info.online.email</name>
    </user-attribute>
    </portlet-app>

    Hello i had exactly the same error, but not with file upload.
    I'm sure you have in your application lib directory to jars which aren't compatible to each other.
    And the problem occured between my myfaces and tomahawk jars .
    See this page:
    http://wiki.apache.org/myfaces/CompatibilityMatrix
    It tells you which myfaces and tomahawk jars you can use together.
    Hope it can help.
    bye

  • Error while uploading files to AWS S3

    Hello Experts
    SAP PI 7.31
    I am working on the following scenario. SAP PI receives a file attachment from SOAP response and the same needs to be uploaded to AWS S3 using REST (Advantco REST Adapter) (PUT Method):
    File --> SAP PI --> REST
                     ||
                   SOAP
    To do this without using BPM, I am using RequestResponseBean and ResponseOnewayBean in Sender_File Adapter. In the module parameters, I have mentioned the details of the REST receiver channel. I am using PUT method in Receiver_REST and have checked option "keep attachments"
    When I run this interface, the message fails while sending the file to Receiver_REST with the following errors:
    Sender_File: ResponseOnewayBean - Attempt to process file failed with com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.af.lib.ra.cci.XIAdapterException
    Receiver_REST Adapter: Error: Broken pipe (Software version: 1.0.11)
    This is the first time we are using REST Adapter to upload files to AWS S3. Could you please provide pointers on the same?
    Thanks
    Jaya

    05/08/17 11:22:31 java.io.IOException: java.io.IOException: sqlldr: not found
    Does the client m/c have sqlldr installed (it will need Oracle client installation)? Does it have the ORACLE_HOME/bin directory in whatever path is appropriate for the client OS?
    Cheers, APC

  • Fileaccess.httpUploadBean doesn't upload file in Jdevelper 9.0.3

    Hi,
    I am using Jdevelper 9.0.3 to develop a jsp Based File Upload Utility.
    I have attached Liberary "JSP RUNTIME" which reffers to "ojsp.jar","ojsputil.jar","oc4j.jar","servlet.jar","ojc.jar".
    while running the code for file upload, file doesn't get uploaded. I am not getting any exceptions too.
    But the same pease of code with same liberary "JSP RUNTIME" is working absolutly fine(Uploading File), when i am running it using Jdeveloper10.1.2, and This is Strange to me.Actualy i need to use Jdeveloper9.0.3 only.Please let me know if any patch is required to apply in Jdeveloper9.0.3.
    Please find the code below and help.
    fileaccess.properties
    fileaccess.basedir = C:/
    fileUpload.jsp
    <html><body>
    <form name = "formname" action="beanUploadExample.jsp" method=POST ENCTYPE="multipart/form-data" />
    <br>MailID: <INPUT TYPE="text" NAME="strMailId" />
    <br> File to upload: <INPUT TYPE="FILE" NAME="File" SIZE="50" MAXLENGTH="120" >
    <br><INPUT TYPE="Submit" NAME="Submit" VALUE="Send" >
    <INPUT type="reset" name="reset" value = "Cancel">
    </form>
    </body></html>
    beanUploadExample.jsp
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page language="java"
    import="java.util.*,java.io.*, oracle.jsp.webutil.fileaccess.*" %>
    <html><body>
    <SCRIPT language="JavaScript">
    function formAction()
    if (document.upForm.forward.value == "true")
    {//tOMORROW PASS THE FILE NAME WITH ACTION PARAM
    //alert("Submit");
    document.upForm.action = "uploadco"
    document.upForm.submit();
    </SCRIPT>
    <Form name="upForm" method ="post" > <!--action ="beanUploadExample.jsp" >-->
    <%
    String userdir = "Test";
    String strFlag = "";
    String strFileName ="";
    String strDirName ="";
    String strAbsoluteName ="";
    %>
    <jsp:useBean id="upbean"
    class="oracle.jsp.webutil.fileaccess.HttpUploadBean" >
    <jsp:setProperty name="upbean" property="destination" value="<%=userdir%"/>
    </jsp:useBean>
    <%
    try{
    upbean.setBaseDir(application, request);
    String str = upbean.getDestination();
    // application.getServletContextName();
    //out.println("The Servlet Context is "+strContext) ;
    out.println("The value of Destination is "+str) ;
    upbean.upload(request);
    String name = upbean.getParameter("strMailId");
    out.println("name-----:::::: "+name) ;
    String strDestType = upbean.getDestinationType();
    out.println("strDestType-----:::::: "+strDestType) ;
    Enumeration fileNames = upbean.getFileNames();
    while (fileNames.hasMoreElements()) {
    strFlag = "true";
    strFileName = (String)fileNames.nextElement();
    out.println("strFileName File Name Is:::::"+strFileName);
    strAbsoluteName = strFileName.substring(4,strFileName.length());
    catch(IOException ex)
    out.println("IOException is =="+ex.toString());
    catch(Exception ex)
    out.println("IOException is =="+ex.toString());
    %>
    <table width = 50% align="center" >
    <tr>
    <td align ="center"><input type = "Button" name ="Submit" value="Ok" onclick="formAction()" ></td></tr></table>
    </Form>
    </body></html>

    Hi,
    I am using Jdevelper 9.0.3 to develop a jsp Based File Upload Utility.
    I have attached Liberary "JSP RUNTIME" which reffers to "ojsp.jar","ojsputil.jar","oc4j.jar","servlet.jar","ojc.jar".
    while running the code for file upload, file doesn't get uploaded. I am not getting any exceptions too.
    But the same pease of code with same liberary "JSP RUNTIME" is working absolutly fine(Uploading File), when i am running it using Jdeveloper10.1.2, and This is Strange to me.Actualy i need to use Jdeveloper9.0.3 only.Please let me know if any patch is required to apply in Jdeveloper9.0.3.
    Please find the code below and help.
    fileaccess.properties
    fileaccess.basedir = C:/
    fileUpload.jsp
    <html><body>
    <form name = "formname" action="beanUploadExample.jsp" method=POST ENCTYPE="multipart/form-data" />
    <br>MailID: <INPUT TYPE="text" NAME="strMailId" />
    <br> File to upload: <INPUT TYPE="FILE" NAME="File" SIZE="50" MAXLENGTH="120" >
    <br><INPUT TYPE="Submit" NAME="Submit" VALUE="Send" >
    <INPUT type="reset" name="reset" value = "Cancel">
    </form>
    </body></html>
    beanUploadExample.jsp
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page language="java"
    import="java.util.*,java.io.*, oracle.jsp.webutil.fileaccess.*" %>
    <html><body>
    <SCRIPT language="JavaScript">
    function formAction()
    if (document.upForm.forward.value == "true")
    {//tOMORROW PASS THE FILE NAME WITH ACTION PARAM
    //alert("Submit");
    document.upForm.action = "uploadco"
    document.upForm.submit();
    </SCRIPT>
    <Form name="upForm" method ="post" > <!--action ="beanUploadExample.jsp" >-->
    <%
    String userdir = "Test";
    String strFlag = "";
    String strFileName ="";
    String strDirName ="";
    String strAbsoluteName ="";
    %>
    <jsp:useBean id="upbean"
    class="oracle.jsp.webutil.fileaccess.HttpUploadBean" >
    <jsp:setProperty name="upbean" property="destination" value="<%=userdir%"/>
    </jsp:useBean>
    <%
    try{
    upbean.setBaseDir(application, request);
    String str = upbean.getDestination();
    // application.getServletContextName();
    //out.println("The Servlet Context is "+strContext) ;
    out.println("The value of Destination is "+str) ;
    upbean.upload(request);
    String name = upbean.getParameter("strMailId");
    out.println("name-----:::::: "+name) ;
    String strDestType = upbean.getDestinationType();
    out.println("strDestType-----:::::: "+strDestType) ;
    Enumeration fileNames = upbean.getFileNames();
    while (fileNames.hasMoreElements()) {
    strFlag = "true";
    strFileName = (String)fileNames.nextElement();
    out.println("strFileName File Name Is:::::"+strFileName);
    strAbsoluteName = strFileName.substring(4,strFileName.length());
    catch(IOException ex)
    out.println("IOException is =="+ex.toString());
    catch(Exception ex)
    out.println("IOException is =="+ex.toString());
    %>
    <table width = 50% align="center" >
    <tr>
    <td align ="center"><input type = "Button" name ="Submit" value="Ok" onclick="formAction()" ></td></tr></table>
    </Form>
    </body></html>

Maybe you are looking for