Upload File Validation Urgent pls..........................

hi ,
i want to validate FileAttachment If i give some junk data in IE7 It is not executing that page but it's working fine in IE6 And if i give more than 2MB,it is not enter inside the if loop ( if(attachmentFileName != null {...... }) at all .this is my code
if(attachmentFileName != null){
try{
InputStream inputStream = new FileInputStream(attachmentFileName);
if(attachmentFileName.length() > ApplicationDefs.TWO_MB){ addActionError("Sorry your file is size is greater than 2 MB");
return;
if(inputStream.available() == 0){
addActionError("Invalid file format");
return;
if(!isValidFileFormat(attachmentFileName)){
addActionError("Invalid file format");
return;
}catch(FileNotFoundException fne){
addActionError("Uploaded file not found");
return;
}catch(IOException io){
addActionError("Unable to read the uploaded file");
return;
}//end of try-catch
}//end of if
showing the following errors
15:36:47,339 ERROR [MultiPartRequest] org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (2264141) exceeds the configured maximum (2097152)
15:36:52,839 ERROR [FileUploadInterceptor] the request was rejected because its size (2264141) exceeds the configured maximum (2097152)
please any one help me
sreenu
Thank You

I looked at the sample code, (getCategory() == null ). I wasn't sure if it's ok for me to validate the contentType sheet in the ActionForm, it's not a String. I moved the validation to the Action after its not working. I placed the code back to the ActionForm and debugged the code and ti worked. Thanks.

Similar Messages

  • Reversal of stock upload file:- Urgent

    Gurus,
        By mistake at intial stock upload file is  upladed twice, how could i reverse  the same. I uploaded  through   T -code MB1C/ Mvt type 561; and showing at 998 storage type( interemediate bins). How could I will reverse the excess stock from the same.
    Please let me know the process . its is urgent. by what logic shoulsd I make  BDCetc.
    Regds,
    Sanjay rahangdale
    [email protected]

    Hi,
    re run the file again but this time with a 562 movement type, this should reverse the error exactly how you want it.
    Steve b

  • Image Upload probelm - Very Urgent. Pls help!!!

    Hi All,
    I am facing very strange problem while uploading a image file (.JPG file) thru a web dynpro view.
    I am accepting a image file from view and uploading it to a ftp server.
    There are two abnormal results I have observed. It does NOT happen for every image upload. But it has been observed to happen during peak Internet hrs. (image size can range from 1MB to 7-8 MBs)
    When 'Upload' button is clicked, one of the following thing happens:-
    1. After taking loooong time (processing circle rotates), browser screen goes totally blank. That is, browser goes into state as if no page is opened (white screen)
    2. After taking loooong time, empty form re-appears. ( ie the view in which i had submitted data and pressed 'Upload')
    I have tried tracing errors in default trace. but no error or exception is displayed !!!
    Following is the code i'm using for uploading file. ==>
    try {
    URL myUrl = new URL("ftp://<some address>");
    FtpURLConnection myConnection = new FtpURLConnection(myUrl);
    myConnection.connect();
    OutputStream out = myConnection.getOutputStream();
    out.write(wdContext.currentPhotosElement().getPhoto1());
    out.close();
    myConnection.close();
    } catch (Exception e) {
    System.err.println("\n\n$$$$$$$$$$$$$Exception in image upload $$$$$$$$$$$$$\n\n");
    e.printStackTrace();
    Please help me as this system is live and lot of users are complaining as they are not able to upload their images..
    Awaiting for reply ..
    regards,
    Amey

    Hi,
    Does anybody have any idea about how the file data (byte stream) flows from Client's machine browser to Web Dynpro's context's element??
    As per my observation and tracing, it is first loading byte array frm client's machine to view's corresponding context node.. And then only it is proceeding with further actions.
    Now in my case, user may upload files ranging frm size 6MB to 10MB, web dynpro application either refreshes or times out during this transfer. I didnt even started FTP process to upload byte[] to remote server !!!
    So how can we increase this speed of transfer from  client's machine to context element ??
    regards,
    Amey

  • Urgent - pls help - Problem while inserting binary file into Oracle DB

    Hi,
    I am trying to insert binary files into a Blob column in a Oracle 10G table.
    The binary files would be uploaded by the web users and hence come as multipart request. I use apache commons upload streaming API to handle it. Finally i am getting a input stream of the uploaded file.
    The JDBC code is
    PreparedStatement ps=conn.prepareStatement("insert into bincontent_table values(?)");
    ps.setBinaryStream(1,inStream,length);
    My problem starts when i try to find the length of the stream. available() method of inputstream does not return the full length of the stream. so i put a loop to read thru the stream and find the length as shown below
    int length=0;
    while((v=inStream.read())!=-1)
    length++;
    Now, though i got the length, my stream pointer has reached the end and i cant reset it(it throws an error if i try).
    So i copied the stream content to a byte array and created an ByteArrayInputStream like this.
    tempByteArray=new byte[length];
    stream.read(tempByteArray,0,length);
    ByteArrayInputStream bais=new ByteArrayInputStream(tempByteArray);
    Now if i pass this bytearray input stream instead of the normal input stream to the prepared statement's setBinaryStream() method it throws an error as
    "ORA-01460: unimplemented or unreasonable conversion requested".
    Now how to solve this?
    My doubts are ,
    1) preparedStatement.setBinaryStream(int parameterIndex, InputStream x, int length) expects an inputstream and its length. if i have the stream how to find its length with out reading the stream?
    2) Also as the length parameter is a integer, what if i have a large binary file whose length runs more than the capacity of integer
    3) Alternatively there is a setBlob(int i, Blob x) in prepared statement. But how to instantiate a Blob object and set it here
    4) Is there any better way to do this.
    Thanks in advance

    "ORA-01460: unimplemented or unreasonable conversion
    requested".When the setBinaryStream method is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as a LONGVARBINARY or a BLOB (reference: javadoc)
    1) preparedStatement.setBinaryStream(int parameterIndex,
    InputStream x, int length) expects an inputstream and its length. if i
    have the stream how to find its length with out reading the stream?no. stream may have no specified length. i think you have wrong understanding about stream.
    2) Also as the length parameter is a integer, what if i have a large
    binary file whose length runs more than the capacity of integer
    3) Alternatively there is a setBlob(int i, Blob x) in prepared statement.
    But how to instantiate a Blob object and set it here
    4) Is there any better way to do this.use ps.setBlob(1, instream) instead

  • Urgent !!!!!!!!!!!!!Uploading File problem

    Hi I stucked on a problem...... I want to upload file from html page....On this page I want only a upload button so that when I click on this button file will upload from my client m/c to server m/c.... I have code n all but browse button on html page....now I want to remove this browse button n want to give the file path somewhere in the code itself........so that on html page there will only the uplod button and by click on this button file will upload from client to server.......server path already there in code.....Please do the needful  Abhishek  I m putting the code here:-  FileUpload.java  /* upload-FileUpload.java  NOTE: This file is a generated file. Do not modify it by hand! */  package upload;   //custom imports for FileUpload //add your custom import statements here  import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import com.oreilly.servlet.MultipartRequest; import java.util.*;   public class FileUpload extends javax.servlet.http.HttpServlet { protected boolean create() throws java.lang.Exception {  return true; }   public FileUpload() { // Constructor.  } private void unhandledEvent( String listenerName, String methodName, java.lang.Object event ) {  } /** * destroy Method */  public void destroy() { super.destroy(); // TODO: implement } /** * doGet Method */  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("abhishek"); response.setContentType( "text/html" );  PrintWriter out = response.getWriter();  out.println("<HTML>");  out.println("<HEAD><TITLE>FileUpload</TITLE></HEAD>");  out.println("<BODY>");  out.println("<H1>FileUpload</H1>");  out.println("Hello World!");  out.println(" Default Implementation From PowerJ  ");  out.println("</BODY></HTML>");   // TODO: implement } /** * doPost Method */  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {   PrintWriter out = response.getWriter();  try{ response.setContentType("text/html"); out.println("<HTML>"); out.println("<head><Title>Decoded Uploaded File</title><head>");  out.println("<body>"); out.println("<H1>UploadFile</h1>");  // path must be absolute to upload dir // This is the decoder class that extracts the parameters and transfer file // request argument = Http input stream // c:\\temp\\upload = directory to save file // 15*1024*1024 = 15mb max size file MultipartRequest multi = new MultipartRequest(request, "c:\\temp\\upload",15*1024*1024);   // Lists form parameters out.println("Params:"); Enumeration params = multi.getParameterNames(); out.println("<pre>");  while (params.hasMoreElements()) { String name = (String)params.nextElement(); String value = multi.getParameter(name); out.println(name + " = " + value); }  out.println("</pre>");   // Show details of uploaded file out.println("Files:"); Enumeration files = multi.getFileNames();  out.println("<pre>"); while (files.hasMoreElements()) { String name = (String)files.nextElement(); String filename = multi.getFilesystemName(name); String type = multi.getContentType(name); File f = multi.getFile(name); out.println("name: " + name); out.println("filename: " + filename); out.println("type: " + type); if (f != null) { out.println("f.toString(): " + f.toString()); out.println("f.getName(): " + f.getName()); out.println("f.exists(): " + f.exists()); out.println("f.length(): " + f.length()); out.println(); } out.println("</pre>"); }  }catch (Exception e){ out.println("<pre>"); e.printStackTrace(out); out.println("</pre>"); } out.println("</body></html>"); } /** * init Method */  public void init(ServletConfig config) throws ServletException { super.init(config); // TODO: implement } /**************************************** * data members ****************************************/   // add your data members here }  --------------------------------------------------------------------------------------------------  UploadFile.html  <html>  <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>File Upload using EAS</title> </head>  <body>  <form method="POST" enctype="multipart/form-data" action="upload/FileUpload">  <b>File Upload using EAS </b>    Select file to send: <input type="file" name="name" size="30">    Your Name: <input type="input" name="yourname" size="20">     <input type="submit" value="Send File" name="submit">   </form>  </body>  </html> ----------------------------------------------------------------------------------------------  You can download the oreilly files from :- (same code is also here)  http://www.sybase.com/detail?id=1011664

    I m putting the code again with code tags:-
    code is here
    FileUpload.java
    package upload;
    //custom imports for FileUpload
    //add your custom import statements here
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import com.oreilly.servlet.MultipartRequest;
    import java.util.*;
    public class FileUpload extends javax.servlet.http.HttpServlet
    protected boolean create() throws java.lang.Exception
    return true;
    public FileUpload()
    { // Constructor.
    private void unhandledEvent( String listenerName, String methodName, java.lang.Object event )
    * destroy Method
    public void destroy()
    super.destroy();
    // TODO: implement
    * doGet Method
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    System.out.println("abhishek");
    response.setContentType( "text/html" );
    PrintWriter out = response.getWriter();
    out.println("<HTML>");
    out.println("<HEAD><TITLE>FileUpload</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<H1>FileUpload</H1>");
    out.println("Hello World!");
    out.println("
    Default Implementation From PowerJ
    out.println("</BODY></HTML>");
    // TODO: implement
    * doPost Method
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    PrintWriter out = response.getWriter();
    try{
    response.setContentType("text/html");
    out.println("<HTML>");
    out.println("<head><Title>Decoded Uploaded File</title><head>");
    out.println("<body>");
    out.println("<H1>UploadFile</h1>");
    // path must be absolute to upload dir
    // This is the decoder class that extracts the parameters and transfer file
    // request argument = Http input stream
    // c:\\temp\\upload = directory to save file
    // 15*1024*1024 = 15mb max size file
    MultipartRequest multi = new MultipartRequest(request, "c:\\temp\\upload",15*1024*1024);
    // Lists form parameters
    out.println("Params:");
    Enumeration params = multi.getParameterNames();
    out.println("<pre>");
    while (params.hasMoreElements()) {
    String name = (String)params.nextElement();
    String value = multi.getParameter(name);
    out.println(name + " = " + value);
    out.println("</pre>");
    // Show details of uploaded file
    out.println("Files:");
    Enumeration files = multi.getFileNames();
    out.println("<pre>");
    while (files.hasMoreElements()) {
    String name = (String)files.nextElement();
    String filename = multi.getFilesystemName(name);
    String type = multi.getContentType(name);
    File f = multi.getFile(name);
    out.println("name: " + name);
    out.println("filename: " + filename);
    out.println("type: " + type);
    if (f != null) {
    out.println("f.toString(): " + f.toString());
    out.println("f.getName(): " + f.getName());
    out.println("f.exists(): " + f.exists());
    out.println("f.length(): " + f.length());
    out.println();
    out.println("</pre>");
    }catch (Exception e){
    out.println("<pre>");
    e.printStackTrace(out);
    out.println("</pre>");
    out.println("</body></html>");
    * init Method
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    // TODO: implement
    * data members
    // add your data members here
    }UploadFile.html
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>File Upload using EAS</title>
    </head>
    <body>
    <form method="POST" enctype="multipart/form-data" action="upload/FileUpload">
    <b>File Upload using EAS </b>
    Select file to send: <input type="file" name="name" size="30">
    Your Name: <input type="input" name="yourname" size="20">
    <input type="submit" value="Send File" name="submit">
    </form>
    </body>
    </html>[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Probelm on assigning valid hosting server  path to upload files

    our domain name is domainname.com
    We have written complete code for uploading files into server ,we need some information about Path .
    Now the question is ,
    we have uploaded project into Public_html directory on server .
    How can i give path in our code to recognize Public_html directory......
    i used the below path
    /home/domainname/public_html/Contents....
    Contents is folder stored on public_html ...still giving error on the path ..
    please can send me correct path ,how we can recognize a Contents folder on Public_html

    If you want to upload from the client to the server, you can't from java code in a JSP page.
    Remember that the JSP page runs on the SERVER.
    The way to upload a file using HTML is with an input type="file"
    Alternatively use an applet / activex control to choose/upload the file with.

  • Architectural Problem with file upload feature. URGENT!!!

    Hi,
              We have an architecture in a production site which has iPlanet in the front & WebLogic at the back. The web-tier and the middle-tier both reside on the WebLogic server & only the static assets (images, PDFs etc.) are serviced by iPlanet. Recently we had to incorporate a new feature to our existing site to allow the user to upload images onto the server. The problem with this is that since our web-tier is in WebLogic, the uploaded file would reside in the WebLogic server's document root and will not be accessible to the iPlanet server. Is there any way that I can store the images directly in iPlanet even though the servlets reside on WebLogic. I know this query sounds a bit weird & I'm asking for too much but I also have this feeling the architecture of our site is not very different from a lot of other sites & other sites also have upload functionalities, so how do they go about dealing with this problem. Porting the web-tier to iPlanet is not a solutions since there are a lot parties involved & we cannot at this point take that decision.
              Would really appreciate any help from you guys.
              Thanks in advance,
              VD.
              

    u can have AppServers serve the image if u want to.
              u just need to set the path correctly and save them in the right directory.
              we are already doing it with Iplanet and we wrote a sample for Weblogic6.1 too.
              if i remember correctly u need to put the image directiry say "imageDirectory" in "wlserver6.1"
              then u need to access via http://apache_webserver_box:80/weblogic_identifier/imageDirectory/myimage.jpg
              Hope it helps!!!
              -aseem
              vikram wrote:
              > Hi,
              > We have an architecture in a production site which has iPlanet in the front & WebLogic at the back. The web-tier and the middle-tier both reside on the WebLogic server & only the static assets (images, PDFs etc.) are serviced by iPlanet. Recently we had to incorporate a new feature to our existing site to allow the user to upload images onto the server. The problem with this is that since our web-tier is in WebLogic, the uploaded file would reside in the WebLogic server's document root and will not be accessible to the iPlanet server. Is there any way that I can store the images directly in iPlanet even though the servlets reside on WebLogic. I know this query sounds a bit weird & I'm asking for too much but I also have this feeling the architecture of our site is not very different from a lot of other sites & other sites also have upload functionalities, so how do they go about dealing with this problem. Porting the web-tier to iPlanet is not a solutions since there are a lot parties involved & we cannot at this point take that decision.
              >
              > Would really appreciate any help from you guys.
              >
              > Thanks in advance,
              > VD.
              

  • 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
    -------------------------------------------------------------------

  • How to upload file from a client machine to server machine

    hei evryone!
    can anyone pls help me on how i can upload file from a client machine to another machine (or server). using jsp.Then later on, i can also retrieve the names of these files to place it as values for option tag in an html form.I have a seperate screen for uploading the file and the screen for displaying all the files that were uploaded on the server...
    any sample code/ ideas would be much appreciated.Thx!!!!

    hei evryone!
    can anyone pls help me on how i can upload file from a client machine to another machine (or server). using jsp.Then later on, i can also retrieve the names of these files to place it as values for option tag in an html form.I have a seperate screen for uploading the file and the screen for displaying all the files that were uploaded on the server...
    any sample code/ ideas would be much appreciated.Thx!!!!

  • How to upload file from client to server in servlets.

    actually in my application i have to upload file from client m/c to server.
    it is not possible through file i/p stream as fileStreams does not work on network. Please mail me if you have any solution to this.
    Thank's in advance............

    Haii roshan
    Pls go through this thread..
    http://forum.java.sun.com/thread.jspa?forumID=45&threadID=616589
    regards
    Shanu

  • Using ABAP Webdynpr How to Upload File and download file in SAP R/3

    Hi SAP GURUS ,
                             I wanted to save employee profile from ESS to SAP so i am creating ESS Application .
    For that I go with BDS Approach and create test program for this  I got success while uploading file in my folder
    which i have created with the help of class and content repository . but when i Using ABAP Webdynpro , i got error FM "BDS_BUSINESSDOCUMENT_CREATEF"  message " error_kpro " .
                           Also I wanted to use KM for storage of Documents and wanted to retrive with help of ABAP Webdynpro .
                           So pls tell me / mailed me the process , approach and if you have examples .
        Thanks in Advance ,
         Vishwassap at gmail

    Hi Vishwas,
    Check out the thread [Efficient way of saving documents uploaded|Re: Efficient way of saving documents uploaded by users; and check the blog by Raja Thangamani.
    Also check the thread [Export Images through Function Modules   |Export Images through Function Modules;.
    Hope it helps you.

  • Questions about OAS Portal Forms to upload files

    Hello,
    I have quetions, about uploading files, see I need to creat a form that will be used by other people to upload information that later will be presented as downloads in the portal...
    so I created a form in my provider with a file (binary) field, and it mimes to my table in the DB, to the field "Archivo", then what I do is use a omniportlet and using HTML format I present like a link using the info in the field Archivo
    and when I clic on it it takes me to this link
    http://desarrollo06:7778/pls/portal/38173.PDF
    but the file I uploaded does not appear
    can aniyone help me to solve this?
    thanks in advances for the suggestions and your time ^_^

    The method you used to setup upload of file seems fine. I suppose you would have used a blob type to save the file in your db table.
    basically, you can develop a report offering a link calling perhaps a procedure which would query from the table and download the file.
    In that procedure, you would look for the file (vblob) and the mime_type from that table using a sql-query. then use them to setup the mime type for the http protocol, and download the file as follows.
    owa_util.mime_header(mime_type);
    owa_util.http_header_close;
    wpg_docload.Download_File(vblob);
    hope that helps!
    AMN

  • Itunes Producer Problems Uploading - File not saving - file does not Exist.

    Can someone please help me out, this problem is killing me. I've uploaded over 200 UPC Albums using Old G3 and Elderly ITunes Producer, but apple asked me to upgrade, so new machine to me Macmini maverics 10.9.? ITunes Producer 3.1.
    So I click open ITunes producer 3.1. Click on make project from Audio
    Files. Name and Save the project in Music-ITunes Producer-Playlists.
    Plug in my external Flash drive and import the 40 Audio files for the
    project. I am using an external flash drive as I can’t get ITunes Producer to
    see my internal hard disk, I do not know if this is normal??
    Go through the process of saving the project to Music – ITunes Producer –
    Playlists – in this case 5060101121313
    I then go through name all Tracks and make sure that all Data is correct.
    Then when I finally go to either save the document or send it to you I get the
    first Screen shot saying
    "The Document "5060101121313" COULD NOT BE SAVED. The File does not exist".
    As I say I have delivered 200 UPC’s to you with the old software and never
    had any problems, I am in urgent need of making significant delivery to you so
    would appreciate you help ASAP.
    Paul

    I have been victorious. Now I am going to post my solution for all those that may have the same problem in the future. I'll even throw in a few key words so it will be more easily found by the search engine.
    Connection conn = null;
            try{
                //connect to database
                DAOManager dao = new DAOManager();
                conn = dao.connectToDB();
                String query = "update ASSIGNMENT set file_object = ?, filename = ?, filetype = ? where a_key = 1"; //sql query
                PreparedStatement pstmt = conn.prepareStatement(query);
                ByteArrayOutputStream baostream = new ByteArrayOutputStream();
                //write to output stream
                byte[] buffer = new byte[1024];
                int len = -1;
                while ((len = instream.read(buffer)) >= 0 )
                    baostream.write(buffer, 0, len);
                baostream.flush();
                byte[] filebytes = baostream.toByteArray();
                baostream.close();
                pstmt.setBytes(1,filebytes); //set blob
                pstmt.setString(2,filename);
                pstmt.setString(3,filetype);
                pstmt.executeUpdate();
                pstmt.close();
            catch (SQLException e) {
                System.out.println(Tools.getLoggingDate() + " upload() Error uploading file -- " + e);
                e.printStackTrace();
            catch (Exception e) {
                System.out.println(Tools.getLoggingDate() + " upload() Error: " + e);
            finally {
                try{
                    conn.close();
                }catch (SQLException e) {}
            }Keywords: setBinaryStream(), setBytes(), MySQL, upload file, InputStream, Blob

  • How to add new row and update existing rows at a time form the upload file

    hi
    How to add new row and update existing rows at a time form the upload file
    example:ztable(existing table)
    bcent                      smh            nsmh         valid date
    0001112465      7.4                       26.06.2007
    0001112466      7.5                       26.06.2007
    000111801                      7.6                       26.06.2007
    1982                      7.8                       26.06.2007
    Flat file structure
    bcent                       nsmh         valid date
    0001112465     7.8     26.06.2007  ( update into above table in nsmh)
    0001112466     7.9     26.06.2007  ( update into above table in nsmh) 
    000111801                     7.6      26.06.2007 ( update into above table in nsmh
    1985                      11              26.06.2007   new row it should insert in table
    thanks,
    Sivagopal R

    Hi,
    First upload the file into an internal table. If you are using a file that is on application server. Use open dataset and close dataset.
    Then :
    Loop at it.
    *insert or modify as per your requirement.
    Endloop.
    Regards,
    Srilatha.

Maybe you are looking for